in reply to Re^2: Getopt, regexen, and newlines
in thread Getopt, regexen, and newlines
You don't have to know either Perl or sed to use itYou don't have to know Perl or sed to use the one-liners, either. You just need to know those particular commands. The amount of knowledge isn't much different in any case. The one advantage of your script is that it will explain its calling syntax (if the user remembers the -h argument).
I'd probably rewrite it without Getopts. Just take three parameters. Spit out the help if there aren't three parameters. Users can specify '' for an empty parameter. Something like:
my ($from, $to) = (shift, shift); @ARGV == 1 or die "Usage: $0 from_string to_string filename\n"; while (<>) { s/\Q$from/$to/g; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Getopt, regexen, and newlines
by apotheon (Deacon) on Oct 12, 2005 at 19:02 UTC |