Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How to awk a grep result in-script

by hippo (Bishop)
on Nov 14, 2019 at 18:51 UTC ( [id://11108691]=note: print w/replies, xml ) Need Help??


in reply to How to awk a grep result in-script

How do I perform the equivalent of "awk {'print $1,$2,$8'}" in perl?

Here is the answer to this particular question, although see haukex's reply (++) for some better approaches regarding the wider topic of shelling out.

#!/usr/bin/env perl use strict; use warnings; my $in = 'z y x w v u t s r q p'; my @chars = split (/ /, $in); print "@chars[0,1,7]\n";

Note that arrays in Perl by default start indexing from zero. Don't change this default unless you enjoy being hunted down by your co-developers.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found