On Aug 16, 7:21 pm, [EMAIL PROTECTED] (Mr. Shawn H. Corey) wrote:
> Paul Lalli wrote:
> > So define the subroutine in the same scope as the array.  Move the
> > subroutine into the if-statement as well.
>
> Huh?

What part of what I said did you not understand?

> Please speak Perl.

Please learn some Perl.

> Subroutines are global.  Unless they're anonymous.  And even then, they
> are.  It's just difficult to get a hold on them.

Nothing in this statement contradicts my post.

#!/usr/bin/perl
use strict;
use warnings;
{
   my $foo;
   sub one {
        print $foo;
   }
}

sub two {
   print $foo;
}

&one has access to $foo.  &two does not, and will cause a syntax
error.

Google for "closure" if you still don't understand.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to