Re: Local and global at the same time?

2010-04-20 Thread Shawn H Corey
newbie01 perl wrote: 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 w

Re: Local and global at the same time?

2010-04-20 Thread Jeff Pang
On Wed, Apr 21, 2010 at 8:38 AM, newbie01 perl wrote: > 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() > { >

Local and global at the same time?

2010-04-20 Thread newbie01 perl
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