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

comment on

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

Thanks, you're right.

Just for the record: I had confused myself unnecessarily by not putting a separator in between the cat of file1 and file2. Which made me wonder why the magical file handle is only being advanced by eof() at the very end, and not at every file boundary.  When you do it properly, however, i.e. something like

cat file1 echo --- cat file2

the output is

... --- perl output to stdout --- line3 opt=bar --- cat after --- line1 line2 --- line3 line1 line2

which shows that line3 of the first file does in fact belong to file2 after the processing...

P.S. I've now settled on suggesting my collegue

perl -i -pe '$f||=s/opt=.*/opt=bar/; $_.="opt=bar\n" if !$f && !@ARGV +&& eof' files...

(but unfortunately it took a little too long to get working to leave an "it's easy with Perl" impression — that's my fault, however :)


In reply to Re^4: perl -i -pe ... with eof() testing by Anonyrnous Monk
in thread perl -i -pe ... with eof() testing by Anonyrnous Monk

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 lurking in the Monastery: (3)
As of 2024-04-19 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found