develooper Front page | perl.beginners | Postings from April 2010

Local and global at the same time?

Thread Next
From:
newbie01 perl
Date:
April 20, 2010 17:38
Subject:
Local and global at the same time?
Message ID:
j2lb74aaa0f1004201738t24397895hdbce8a8a8433ac6b@mail.gmail.com
Hi all,

If I declare a variable x1 outside of the sub that makes it global, right?
Now the question is can I have the same variable x1 as a local variable of a
sub, i.e. will the following work?

$x1 = "cat";

sub sample()
{
   my $x1="dog";
   ...
   ...
}

Just trying to work out some guidelines on using variables, i.e. using
local, my or global and some naming converntion stuff ...

Is there some good links on such guidelines?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About