more useful options | |
PerlMonks |
Re: Getting single element from an arrayby brx (Pilgrim) |
on Nov 05, 2012 at 17:31 UTC ( [id://1002370]=note: print w/replies, xml ) | Need Help?? |
Think to print() as a subroutine: you can write myfunc(...); but myfunc(...)[1]; is wrong. With a "gift package ( )", perl will be happy: myfunc( (...][1] ); perl -e 'sub myfunc { return @_;}; my @res = myfunc(('a','b','c')[1]);print @res;' OKperl -e 'sub myfunc { return @_;}; my @res = myfunc('a','b','c')[1];print @res;' WRONG
English is not my mother tongue. Les tongues de ma mère sont "made in France".
In Section
Seekers of Perl Wisdom
|
|