Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You don't show how $overwrite is used later on, but I don't really see the need for the +0 here, since you've just got two boolean operations. But it doesn't hurt either. Not sure if using chop is good practice, but it works... chop just removes the last character from the string, so if you just want to remove the "y" from "-cy", it's perfectly fine. However, in this code, you seem to be using it unconditionally, so it would also turn "-c" into "-"... (length $function>2) && $function =~ m/..y/ Note that this will also be true for strings like "silly putty". You might want to make your regex more specific by anchnoring it and limiting it to expected characters, something like /^-[cm]y$/, then you don't even need the length check. You could even combine that with removing the y like so: s/^-[cm]\Ky$// (where \K basically means "keep"). By the way, I suggest having a look at Getopt::Long, which can take over a lot of the option processing for you, I showed an example that includes "usage" information here. In reply to Re^3: Length of String
by haukex
|
|