Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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


Comment on awk and tr heresy (Re: Splitting Array with Variable Spaces)
Select or Download Code

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 wandering the Monastery: (10)
As of 2014-08-21 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (138 votes), past polls