Re: how to globalize a lexical variable inside a sub routine

2008-04-11 Thread Peter Scott
On Fri, 11 Apr 2008 00:23:12 +0200, Jenda Krynicky wrote: > Something like > > ... > { > my $cnt; > sub inc { > return ++$cnt; > } > } > > print inc(),"\n"; > print inc(),"\n"; > print inc(),"\n"; Just to put in a plug for the modern conveniences of Perl 5.10: us

Re: how to globalize a lexical variable inside a sub routine

2008-04-10 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Thanks Jenda, Chas.Owens and fellow members. What do you mean by "globalise"? Jenda Looking at the script below, in diagram 1, $capital will not be incremented unless I write it as in diagram 2. Just because I do not want $capital to be reset on each foreach loop, I

Re: how to globalize a lexical variable inside a sub routine

2008-04-10 Thread Jenda Krynicky
Something like ... { my $cnt; sub inc { return ++$cnt; } } print inc(),"\n"; print inc(),"\n"; print inc(),"\n"; Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and c

Re: how to globalize a lexical variable inside a sub routine

2008-04-10 Thread itshardtogetone
Thanks Jenda, Chas.Owens and fellow members. What do you mean by "globalise"? Jenda Looking at the script below, in diagram 1, $capital will not be incremented unless I write it as in diagram 2. Just because I do not want $capital to be reset on each foreach loop, I then have to declare $cap

Re: how to globalize a lexical variable inside a sub routine

2008-04-09 Thread Chas. Owens
On Apr 9, 2008, at 19:30, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] > wrote: Hi, Assuming my script use a strict pragma. If I have a lexical variable declared inside a sub routine and I wish to globalize this lexical variable, what are the various options to globalise this variable? Thanks ##

Re: how to globalize a lexical variable inside a sub routine

2008-04-09 Thread Jenda Krynicky
From: <[EMAIL PROTECTED]> To: Subject:how to globalize a lexical variable inside a sub routine Date sent: Thu, 10 Apr 2008 07:30:32 +0800 > Hi, > Assuming my script use a strict pragma. > If I have a lexical variable declared inside a sub routine and I wish > to globalize this