in reply to Unable to save changes using IO::File

See erikharrison's post. Just a quick comment from me: your code first tries a match and then a substitution which has to find the same match again. It is ok to try substitution on strings where the match would fail - the result will simply be no change. You can just remove the if:
while (<$FRAME_FILE>) { s/$change_on/$change_off/g; }
or simpler s/$change_on/$change_off/g while <$FRAME_FILE>; In fact, you can use substitutions in conditions as well:
if(s/$change_on/$change_off/) { ... }
The block will only execute if a substitution happened.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Unable to save changes using IO::File
by Anonymous Monk on Sep 07, 2002 at 22:55 UTC
    To All Helpers:

    Again thanks for all the help. I now saw what I did wrong and have a better understanding of the logic.

    Also, thanks for the recommendation of TIE::FILE. It works great but unfortunately I'm not able to use it in my final program.

    Well happy programming...