in reply to Search and Replace (UNIX/Linux)

You should try using Getopt::Std rather than the roll-your-own
argument parsing.
Also did you know *nix systems usaully have a utility called sed
to do this type of thing. ;)