develooper Front page | perl.perl5.porters | Postings from October 1999

'my' usage

Thread Next
Andrew Dubry
October 26, 1999 11:33
'my' usage
Message ID:
Apologies in advance if this is not the proper group to ask this question...

I noticed an odd functionality in the use of 'my'. Take a look at this
sample code:

my $nq1 = 5;
$tempvar_name = "nq1";
print "tempvar_name=$tempvar_name\n";
print "nq1=$nq1\n";
print "value of tempvar_name=$$tempvar_name\n";

$$tempvar_name should print out 5. But it DOESNT unless I remove the 'my'
from the $nq1 in the first line.

Is there a lexical reason or something that 'my' does not work the way I
thought it should in the above code??


Web/Internet Programmer (ext. 475)
Cookie Master
Musician's Friend (

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About