Re: use strict and local variables

2006-10-16 Thread Rob Dixon
Raphael Brunner wrote: > > On Mon, Oct 16, 2006 at 07:36:13PM +0800, Jeff Pang wrote: >> >> Raphael Brunner wrote: >>> >>> eg: >>> >>> use strict; >>> my $var = 20; >>> >>> print "$var\n"; >>> &routine; >>> exit; >>> >>> >>> sub routine { >>>print "$var\n"; >>> } >>> >> >> Hi,you can do it by

Re: use strict and local variables

2006-10-16 Thread Jeff Pang
>eg: > >use strict; >my $var = 20; > >print "before: $var\n"; >&routine; >print "after: $var\n"; >exit; > > >sub routine { > $var += 1; >> >} > Hi,you don't need the global vars at all.The same way,you can write it like: use strict; my $var = 20; print "before: $var\n"; $var = routine($va

Re: use strict and local variables

2006-10-16 Thread Ricardo SIGNES
* Raphael Brunner <[EMAIL PROTECTED]> [2006-10-16T08:38:00] > But, my problem is, i must see this variable after the call of the sub. > I'm sorry for the first example, it was inaccurate. But this is ok (I > think) :) (because I have a lot of variables, which I must change in the > sub, I want to d

Re: use strict and local variables

2006-10-16 Thread Raphael Brunner
Thanks for your answer! But, my problem is, i must see this variable after the call of the sub. I'm sorry for the first example, it was inaccurate. But this is ok (I think) :) (because I have a lot of variables, which I must change in the sub, I want to define they as "global" inside my parent-rou

Re: use strict and local variables

2006-10-16 Thread Ovid
--- Jeff Pang <[EMAIL PROTECTED]> wrote: > Hi,you can do it by passing the vars to the subroutine like: > > my $var = 20; > &routine($var); > > sub routine { > my $var = shift; > print $var; > } > I'll second this recommendation because it makes the subroutines more flexible (what if th

Re: use strict and local variables

2006-10-16 Thread Jeff Pang
> >eg: > >use strict; >my $var = 20; > >print "$var\n"; >&routine; >exit; > > >sub routine { > print "$var\n"; >} > Hi,you can do it by passing the vars to the subroutine like: my $var = 20; &routine($var); sub routine { my $var = shift; print $var; } -- Books below translated by

use strict and local variables

2006-10-16 Thread Raphael Brunner
Dear Users is there a possibility to use "use strict" and to define variables in the programm, which are also seen in the subroutines called from this block? I want the same value in the var in the subroutine like before, but without it to define as global. What could I do? Thanks for all ideas a