On Sunday, May 19, 2002, at 10:56 , Postman Pat wrote:

> Greetings,
> I read in the book SAMS Teach Yourself Perl in 21 Days that you can use
> my/local to declare vars. They explanation I got from the book did not do
> much explaining on exactly what the difference is between the two. Can
> someone please shed some light.

you clearly want to follow  Sudarsan Raghavan <[EMAIL PROTECTED]>
advice and scope out http://perl.plover.com/FAQs/Namespaces.html.

A must read.

the short game is

        #!/usr/bin/perl -w
        use strict;

        my $var=1;

        sub thisSub {
                local( $var );

                $var++;
                print "the var is $var\n";

        }

        print "we have var as $var before the call\n"
        thisSub();
        print "we have var as $var after the call\n"


for fun try that without the 'my'.

ciao
drieux

---


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

Reply via email to