OUTPUTuse strict; use warnings; sub pr { my $ref= ref($_[0]) ? $_[0] : \$_[0]; print $ref,"\t"; # print ref of para } check(qw/ Scalar 1 /); check(qw/ Array [1,2] /); check(qw/ Hash {1,2} /); sub check { my ($_title_,$type) = @_; my $_call_ ="pr $type;"; my $code= <<"__EOC"; for (1..3) { $_call_ print "\\n\\t"; #UPDATE for (1..3) { $_call_ } print "\\n"; } __EOC print "\n--- $_title_ \n"; print $code; eval $code; }
Thanks for teh discussion!!!--- Scalar for (1..3) { pr 1; print "\n\t"; #UPDATE for (1..3) { pr 1; } print "\n"; } SCALAR(0x818ad04) SCALAR(0x818acec) SCALAR(0x818acf8) SCALAR(0x818ac +ec) SCALAR(0x818acf8) SCALAR(0x818ad10) SCALAR(0x818acec) SCALAR(0x818ad +10) SCALAR(0x818acec) SCALAR(0x818ad04) SCALAR(0x818ad10) SCALAR(0x818ad +04) --- Array for (1..3) { pr [1,2]; print "\n\t"; #UPDATE for (1..3) { pr [1,2]; } print "\n"; } ARRAY(0x818acf8) ARRAY(0x818acd4) ARRAY(0x818acd4) ARRAY(0x818acd +4) ARRAY(0x818acd4) <----- FAILS ARRAY(0x818acf8) ARRAY(0x818acf8) ARRAY(0x818acf +8) ARRAY(0x818acf8) ARRAY(0x818acd4) ARRAY(0x818acd4) ARRAY(0x818acd +4)
Cheers Rolf
In reply to Re^6: Reference of constants and literals
by LanX
in thread Reference of constants and literals
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |