>I thought I already knew a few things about Perl, but I just found out I
>don't:
>       #!/usr/bin/perl -w
>       use strict;
>       use diagnostics;
>       my $a="27";
>       doit();
>       sub doit{
>               print "$a\n";
>       }
>
>The output of this program is:
>27
>
>Just what I would expect if line 4 had "our" instead of "my".
>What am I missing?

What are you missing?You can write it as your way with no problem usually.
But don't do this under mod_perl,otherwise you'll get lost really.

You may write them like:

use strict;
my $ab=27;   # don't use $a,$b as variable's name since both $a and $b are used 
by perl's 'sort' function by default.
doit($ab);   # pass $ab to the subroutine distinctly

sub doit {
    my $s = shift;
    print "$s\n";
}


--
Books below translated by me to Chinese.
Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/

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


Reply via email to