>-----Original Message-----
>From: Johnson, Shaunn [mailto:[EMAIL PROTECTED]]
>
>
>Howdy:
>
>Have a question about trying to pass the result
>of a sub function to another sub function.
>
>Let's say I have some code like this:
>
>[snip]
>
>sub firstPart {
>       while (<>) {
>       print "Stuff here is: $_\n";
>       }
>
>[/snip]
>
>I'd like to know how can I make $_ available
>for OTHER sub functions if not the entire program.
>I'm trying to get snips of code so I can show 
>you what I'm working with (apologies since it
>isn't my code); I was under the impression that
>I could use my() and pass that info OUTSIDE
>the sub function.


I am probably wrong but I am sure I will be corrected which means I have
learnt something anyway.

my $var;

This means that $var will be available inside a block and the enclosing
block in the following example is the " foreach $item (@filit){THIS IS THE
BLOCK} ". The call to the sub routine easy() is outside the foreach{BLOCK}
so $var is not visible in the easy{BLOCK}. If you use "local $var" then $var
will be allowed to be seen in any local sub routines called from inside the
foreach{BLOCK}. I think you can use "local $something  = $_".   


foreach $item (@filit){
  my $var;
 print "$var";
if (1 = 1){

print "$var";
easy();
        }
}

sub easy{

my $var;
return:

}


Please let me know if I am going off the beaten track with my thoughts.

Harry.












*************************************************************************************
COLT Telecommunications
Registered in England No. 2452736
Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ
Tel. +44 20 7390 3900

This message is subject to and does not create or vary any contractual
relationship between COLT Telecommunications, its subsidiaries or 
affiliates ("COLT") and you. Internet communications are not secure
and therefore COLT does not accept legal responsibility for the
contents of this message.  Any view or opinions expressed are those of
the author. The message is intended for the addressee only and its
contents and any attached files are strictly confidential. If you have
received it in error, please telephone the number above. Thank you.
*************************************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to