[Dancer-users] Using shared variables

Gurunandan Bhat gbhat at pobox.com
Tue Jan 24 20:54:07 CET 2012


Thanks Damien. I see now that vars is the best way to go.

Regards
Gurunandan


On Wed, Jan 25, 2012 at 12:54 AM, damien krotkine <dkrotkine at gmail.com>wrote:

> Ah right, I see,
>
> Well, I'm not an expert at ll in these matters, so I may be totally
> wrong, but I suppose that it depends on how your application is
> deployed. If it's deployed in a way where you have multiple processes
> answering to requests, then the state of the variables can't be saved.
>
> There is the 'vars' function to store a state variable between requests.
>
> On 24 January 2012 20:19, Gurunandan Bhat <gbhat at pobox.com> wrote:
> > I would have used sessions if these shared variables typically
> represented
> > "client states". Unfortunately these variables describe the state of the
> > server (its filesystem for example) and I believe that they are best
> > implemented insulated from sessions which are more suited to client-side
> > stuff.
> >
> > But if there was an error in my logic, I would certainly consider using
> > sessions
> >
> > Thanks
> >
> >
> > On Wed, Jan 25, 2012 at 12:44 AM, damien krotkine <dkrotkine at gmail.com>
> > wrote:
> >>
> >> Don't you want to use sessions to do these sort of things ?
> >>
> >> On 24 January 2012 20:07, Gurunandan Bhat <gbhat at pobox.com> wrote:
> >> > Hi,
> >> >
> >> > I was wondering about the issues using a shared variable in a single
> >> > App.pm
> >> > file. Here is what I mean:
> >> >
> >> > package App.pm
> >> >
> >> > my $var;
> >> >
> >> > // Initialize $var;
> >> > .....
> >> >
> >> > Route1 => sub {
> >> >
> >> > // Modify $var
> >> > ...
> >> > }
> >> >
> >> > Route2 => sub {
> >> >
> >> > // Use $var
> >> > ...
> >> > }
> >> >
> >> > I first call Route1 then when I call Route 2, I expect that I will
> have
> >> > the
> >> > modified value (by Route 1) of $var in route 2. Unfortunately I get an
> >> > undefined value for $var.
> >> >
> >> > Can someone more experienced than I, see if I am doing something
> >> > obviously
> >> > incorrect?
> >> >
> >> > Thank you
> >> >
> >> > Regards.
> >> >
> >> >
> >> > _______________________________________________
> >> > Dancer-users mailing list
> >> > Dancer-users at perldancer.org
> >> > http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120125/c419911d/attachment.htm>


More information about the Dancer-users mailing list