Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-10-08 16:26 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (221 votes), past polls