Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Succint Perl version of Awk

by choroba (Cardinal)
on May 30, 2023 at 08:03 UTC ( [id://11152499]=note: print w/replies, xml ) Need Help??


in reply to Succint Perl version of Awk

TIMTOWTDI:
perl -lane '@F[0,1,2] = ("") x 3; print "@F"' perl -lane 'splice @F, 0, 3, ("") x 3; print "@F"'
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Succint Perl version of Awk
by ikegami (Patriarch) on May 31, 2023 at 01:01 UTC

    Taking advantage that the warnings are off:

    perl -lane'@F[0..2] = (); print "@F"'

    Golfed:

    perl -pale'$_=" @F[3..$#F]"'

    Note that these solutions, like those in the parent, don't "lose the first three columns". They just replace their values with blanks. Just like the awk program does. If you truly want to remove the leading columns (i.e. no leading spaces in the output), then you can use

    perl -pale'$_="@F[3..$#F]"'
Re^2: Succint Perl version of Awk
by Galdor (Sexton) on May 30, 2023 at 10:14 UTC
    LOL - thaksf or your intransigence! it has been noted and appended to my Perl scrapbook... :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11152499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found