Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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; }

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 scrutinizing the Monastery: (5)
As of 2016-08-27 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (380 votes). Check out past polls.