[EMAIL PROTECTED] <> wrote:
> I'm still fighting with that little program, mostly again with
> scoping. I tried to write it the way most of you recommended, passing
> variables to the subroutines. Now my problem is, I get a value back,
> but then it's gone:   
> 
> my $cgi = CGI->new();
> if ( $cgi->param('select_dir') ) {
>     my $sessionids = List_Sessions($server);
>     # here $sessionids is filled, it's a hashref
> } elsif ( $cgi->param('select_files') ) {
>     Kill_Sessions($sessionids);
>     # this $sessionids is empty though...
> } else {
>     List_Dirs($rootpath);
> }

The above code should not compile. If it does, as you imply, then it
means that either you do not have "use strict;" at the start of your
code which is bad news, or that $sessionids is also defined at an outer
scope which is also bad news (it increases the likely hood of confusion
and bugs).

> 
> I get the hashref back fine from List_Sessions($server), but how do I
> get it into the next elsif where I need it? 

Your question suggests to me that you have not sufficiently worked out
the logic of your program yet, and you haven't provided enough
information for us (well me anyway) to try to work it out to make any
useful suggestion. All I can think of are questions, like:

Where and how does $server get initialised, which List_Sessions seems to
depend?

Are the parameters 'select_dir' and 'select_files' mutually exclusive?

Can List_Sessions be called before the if statement?

HTH

-- 
Brian Raven 


=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to