devgoddess has asked for the wisdom of the Perl Monks concerning the following question:
I've been reading the PM write-ups on Tie::File (All hail Dominus!), and they've been great, but I still can't figure out how to conditionally insert lines into a file if they don't exist.
The script I'm writing is supposed to look for server entries, placing them at the end of the file if they're absent or replacing them if incorrect. I've got the replacing part going great. That was easy. However, if the entries aren't present, I need to add them.
How should I go about checking for these entries? Let's say they should look something like this:
server1=myhost1.mydomain.com
server2=myhost2.mydomain.com
I'm sure there's an answer that's stupidly simple and I'm just not seeing it. I really can't make up my mind whether I should be using an array function or if I should be using something from Tie::File itself. Or perhaps there's an entirely different method of which I'm not even aware.
Thanks for any help you can give.
"Size doesn't matter. It's all about speed and performance."
|
|---|