Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by flexvault (Monsignor)
on May 06, 2015 at 17:12 UTC ( [id://1125867]=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

Welcome vcorby,

Your script isn't doing what you think! Please look at 'split'. You need to 'slurp' the file into an array or use a loop to get your first file. (untested)

my @strings = (); open (my $F1, "<", $f1) || die "! open-100 $!";; # open file 1 while ( my $input = <$F1> ) { chomp( $input ); # take off the line breaks $strings[$#strings] = $input; } close $F1;

And life will be easier for you if you start using the 3 parameter 'open' from the beginning:

open (my $F3, ">", $f3 ) || die "! open-300 $!";
This gives you a start and ask more as you get closer.

Note: I like to number my 'die's so it's quicker to find the problem. If you have a 50K line script, you'll be glad you did :-).

Regards...Ed

"Well done is better than well said." - Benjamin Franklin

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-29 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found