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: use 5.10.0; sub inc { state $count; return ++$count; } say inc; say inc; say inc; -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/