[Chicago-talk] get array element from a function return

imran javaid imranjj at gmail.com
Fri Dec 3 12:56:16 PST 2010


> What's wrong with command below?
>
> :) ls -l | perl -nle 'print (split)[0]'
> syntax error at -e line 1, near ")["
> Execution of -e aborted due to compilation errors.

Try this:
ls -l | perl -nle 'print [split]->[0]'
or
ls -l | perl -nle 'split; print @_[0]'

I think "split" does not like being unassigned. it will in that case
assign the return to @_.

-imran


More information about the Chicago-talk mailing list