In addition to the above, as the main utility of aliasing a reference in that way is to simplify the syntax of using the ref, having to type the extra $main::aref[1] or $::aref[1] isn't that much better that typing $aref->[1]
However, you can avoid even this inconvenience by using the vars pragma. eg. use vars '*aref';
Once you have informed the compiler that you intend to use a package global in this way, you no longer need to fully specify the prefix:
#! perl -sw use strict; use vars '*aref'; sub test{ local(*aref) = shift; print "$aref[$_]\n" for 0..@aref; } my(@array) = qw(one two three four five); test(\@array); __END__ C:\test>213248 one two three four five
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.
In reply to Re: Reference optimization (alias/glob)
by BrowserUk
in thread Reference optimization (alias/glob)
by theirpuppet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |