[Edinburgh-pm] A little help with references
Murray
perl at minty.org
Fri May 25 05:47:20 PDT 2007
\(1,2,3) is actually (\1, \2, \3)
\@array is a ref to @array;
So these would work:
perl -e ' @files=<*>;foreach (@files){@{$fs}=stat $_;print "$_:$fs->[7]:\n";}';
perl -e ' @files=<*>;foreach (@files){$fs=[stat $_];print "$_:$fs->[7]:\n";}';
But you could also cut this down to:
perl -e 'foreach (<*>){$fs=[stat $_];print "$_:$fs->[7]:\n";}';
or
perl -e 'foreach (<*>){print "$_:", (stat $_)[7], "\n";}'
Data::Dumper is your friend here.
perl -MData::Dumper -e 'print Dumper \(1,2,3)'
perl -MData::Dumper -e 'print Dumper [1,2,3]'
perl -MData::Dumper -e '@array = (1,2,3) ; print Dumper \@array'
General Data::Dumper rule: if you are calling Data::Dumper::Dumper with
an array or hash, prefix with a \ is probably a good idea.
M.
More information about the Edinburgh-pm
mailing list