raghuprasad241 has asked for the wisdom of the Perl Monks concerning the following question:
I am testing some commands on the command line before I incorporate them into my script. So I am trying to get userid and groupid using the getpwnam function which returns a list. Please see below
perl -e 'print (getpwnam(traveler))[2,3];' syntax error at -e line 1, near ")[" Execution of -e aborted due to compilation errors. perl -e '@temp=(getpwnam(traveler)); print @temp[2,3]' 500500
So does perl allow printing the elements of a list with out using the temporary array to hold the list ? Is there a way to get the first print working ? Or am I doing something wrong ? Appreciate any inputs!
Regards!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List vs array printing in perl
by NetWallah (Canon) on Mar 30, 2016 at 16:17 UTC | |
|
Re: List vs array printing in perl
by Corion (Patriarch) on Mar 30, 2016 at 16:17 UTC | |
|
Re: List vs array printing in perl
by BrowserUk (Patriarch) on Mar 30, 2016 at 16:19 UTC | |
|
Re: List vs array printing in perl
by raghuprasad241 (Beadle) on Mar 30, 2016 at 16:30 UTC | |
by GrandFather (Saint) on Mar 30, 2016 at 21:19 UTC | |
by soonix (Chancellor) on Mar 31, 2016 at 09:25 UTC | |
by ikegami (Patriarch) on Apr 01, 2016 at 15:48 UTC | |
by hippo (Archbishop) on Apr 01, 2016 at 15:54 UTC | |
|