Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

From your initial shell process, you launch a perl process which launches another shell process which launches another perl process. No, this is not the best way to do things. Except for the system() function, you initially seemed to be on the right track. Here's how I would have tackled this:

#!/usr/bin/env perl use strict; use warnings; my $infile = q{pm_read_part_file.in}; my $outfile = q{pm_read_part_file.out}; my $start = 3; my $end = 5; open my $in_fh, q{<}, $infile or die qq{Can't open $infile for reading +: $!}; open my $out_fh, q{>}, $outfile or die qq{Can't open $outfile for writ +ing: $!}; while (<$in_fh>) { next if $. < $start; last if $. > $end; print $out_fh $_; } close $in_fh; close $out_fh;

Here's a sample run with file contents:

en@ganymede: ~/tmp $ pm_read_part_file.pl ken@ganymede: ~/tmp $ cat pm_read_part_file.in Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 ken@ganymede: ~/tmp $ cat pm_read_part_file.out Line 3 Line 4 Line 5 ken@ganymede: ~/tmp $

-- Ken


In reply to Re^3: System command not working by kcott
in thread System command not working by muchyog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found