in reply to global, write-able vars
Quite how you think that ${$timer}++; is going to work when the local var is called $t and the global var $tt?
The first thing you need to do is get (back?) into the habit of enabling strict & warnings.
The (one) way to achieve what you want is to pass a reference to the variable:
#/usr/bin/perl $tt = 1; mt( \$tt ); sub mt { my $t = shift; print " sub: 1 t = ${$t}\n"; ${ $t }++; print " sub: 2 t = ${$t}\n"; } __END__ C:\test>junk55 sub: 1 t = 1 sub: 2 t = 2
|
|---|