Modify patterns inside files

A

ARIEL BOLUDOVSKY

Hello,

I want to open a file, find a string, modify it, and then close the file.

open(FH, "+< $path1") or die "Opening: $!";
@my_ARRAY = <FH>;

# change ARRAY here

seek(FH,0,0) or die "Seeking: $!";
print FH @my_ARRAY or die "Printing: $!";
truncate(FH,tell(FH)) or die "Truncating: $!";
close(FH);

Can anyone describe a quick method to find and modify a given pattern?

Thanks

ARIEL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,946
Members
47,498
Latest member
yelene6679

Latest Threads

Top