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

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! ;)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://39769]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-01-22 04:48 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (231 votes). Check out past polls.