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

Re: search contents of one file and replace with contents of another to make a new file

by marinersk (Priest)
on May 06, 2015 at 17:38 UTC ( [id://1125872]=note: print w/replies, xml ) Need Help??


in reply to SOLVED!!!: search contents of one file and replace with contents of another to make a new file

Seeing open FHwithout matching close FHbothers me. The behavior might be correct -- heck, for all I know, Perl might even by design do the right thing -- but it jangles my OCD nerve.

open (FH, $f1) || die; # open file 1 in a file handle chomp(@strings = <FH>); # take off the line breaks --> close FH; open (FH, $f2) || die; # open file 2 in a file handle $text = join '', <FH>; # joins files 1 and 2? - I don't think I wa +nt to do this... --> close FH;

  • Comment on Re: search contents of one file and replace with contents of another to make a new file
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: search contents of one file and replace with contents of another to make a new file
by Marshall (Canon) on May 07, 2015 at 10:11 UTC
    Yes, a close is the best way.
    However in this situation, a new OPEN for that same filehandle will cause a "close" before the next OPEN happens.
    So basically this "works".
      I love Perl.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found