Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: System command not working

by Jim (Curate)
on Jul 10, 2012 at 22:00 UTC ( #980959=note: print w/ replies, xml ) Need Help??


in reply to Re^2: System command not working
in thread System command not working

It seems someone taught you how to program outside of Perl before she taught you how to program inside of Perl. ;-)

Here's my riff on kcott's script…

#!/usr/bin/env perl use strict; use warnings; use autodie qw( open close ); use English qw( -no_match_vars ); my $input_file = 'input.txt'; my $output_file = 'output.txt'; my $start = 17; my $end = 30; open my $input_fh, '<', $input_file; open my $output_fh, '>', $output_file; LINE: while (my $line = <$input_fh>) { next LINE if $INPUT_LINE_NUMBER < $start; last LINE if $INPUT_LINE_NUMBER > $end; print {$output_fh} $line; } close $input_fh; close $output_fh; exit 0;

And here's a greatly reduced version using <ARGV> and STDOUT instead of hardwiring file names inside the script…

#!/usr/bin/env perl use warnings; while (<>) { next if $. < 17; last if $. > 30; print; }


Comment on Re^3: 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://980959]
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: (6)
As of 2015-01-29 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (228 votes), past polls