Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

awk and tr heresy (Re: Splitting Array with Variable Spaces)

by japhy (Canon)
on Nov 03, 2000 at 02:25 UTC ( #39769=note: print w/replies, xml ) Need Help??


in reply to Splitting Array with Variable Spaces

Why use Perl? Do you have to? I'd do something this trivial in tr and awk if I honestly had a choice: tr -d '%' < INPUT | awk '($11 > $14)'
That, however, removes ALL the % signs, which may be less than optimal. Try this, then: awk '0+substr($11,0,length($11)-1) > 0+substr($14,0,length($14)-1)' INPUT
If you really want to use Perl, here's a command-one-liner: perl -lane 'print if $F[10] > $F[13]' INPUT
or even perl -ape '$_ x= ($F[10] > $F[13])' INPUT
If you need to use it in a program, you'd probably want to stick with the unpack() and substr() solutions given you.

There's more than one way to do it, and dammit, some of them aren't Perl! ;)

$_="goto+F.print+chop;\n=yhpaj";F1:eval

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2016-10-01 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.