my was to define a var like local.

If you have a function and if you define like local, outside that function this 
var was empty (does not exist).

BUT if you define a var like local on main script (and that is your case), your 
var will not work like a local var (it will be seen by all functions).

Regards

Jose Pinto

-----Original Message-----
From: Jorge Almeida [mailto:[EMAIL PROTECTED] 
Sent: sexta-feira, 15 de Dezembro de 2006 10:51
To: beginners@perl.org
Subject: my, my...

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?
TIA.

-- 
Jorge Almeida

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



--
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