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

Michael Potter michael at potter.name
Fri Dec 3 15:54:39 PST 2010


What are you trying to do?

Does this help:
ls -l | perl -nle 'print ((split)[0])'

The parens are being seen at the attached to the print, rather than
wrapping the split.

On Fri, Dec 3, 2010 at 3:13 PM, tiger peng <tigerpeng2001 at yahoo.com> wrote:
> Thanks,
>
> 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.
>
>
> ________________________________
> From: imran javaid <imranjj at gmail.com>
> To: Chicago.pm chatter <chicago-talk at pm.org>
> Sent: Fri, December 3, 2010 2:06:30 PM
> Subject: Re: [Chicago-talk] get array element from a function return
>
> perl -le 'print qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]]'
>
> On Fri, Dec 3, 2010 at 1:59 PM, tiger peng <tigerpeng2001 at yahoo.com> wrote:
>> Hi,
>> To get the weekday name of current day in Perl, I am using some thing like
>> below. I do not like so many punctuation marks. Can it be simpler?
>>
>> perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
>> "Sat")]->[[localtime(time)]->[6]]'
>>
>> _______________________________________________
>> Chicago-talk mailing list
>> Chicago-talk at pm.org
>> http://mail.pm.org/mailman/listinfo/chicago-talk
>>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list