sample code below:
$^I = ".bak";
@ARGV = "sample";
while (<>)
{
s/pattern_to_be_changed/pattern_to_replace/;
print;
}
what this code would do is that it would create a file called sample.bak which is a backup copy of the file named sample in the current directory. Then, it will do a string replace to sample.
neat huh? (for those of you who didn't know this)
This is especially handy when manipulating some program configuration file.
That's my 2 cents of the day.
P.S.
kudos to OtakuPinoy for the help he has given me today. OtakuPinoy, if you are reading this, you know you da man.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment