Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: System command not working

by Jim (Curate)
on Jul 10, 2012 at 22:00 UTC ( [id://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; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-24 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found