Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: System command not working

by jwkrahn (Monsignor)
on Jul 10, 2012 at 09:50 UTC ( #980845=note: print w/ replies, xml ) Need Help??


in reply to System command not working

perl -ne 'print if $. >= 17 && $. <= 30' infile.txt > output.txt

That can be written more simply as:

perl -ne 'print if 17 .. 30' infile.txt > output.txt

The comparison to $. is done automatically.

Your program needs a while loop:

open INFILE, '<', $inFile or die "Can't open $inFile : $!"; open OUTFILE, '>', $outFile or die "Can't open $outFile : $!"; while ( <INFILE> ) { print OUTFILE if 17 .. 30; } close INFILE or die "can't close $inFile : $!"; close OUTFILE or die "can't close $outFile : $!";


Comment on Re: System command not working
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2014-10-24 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (133 votes), past polls