in reply to What makes good Perl code?
Allow me one minor nitpicking.
Even if you don't use some more complicated regex like Marshall mentions, instead of writing
it's better to write eitherif ($current =~ /mA/) { $current =~ s/mA//; ... }
or, if you prefer,if ($current =~ s/mA//) { ... }
if ($current =~ /mA/) { $current =~ s///; ... }
This avoids code duplication so now if someone wants to change your program they can't make a mistake like changing only one of the regexps and causing the code to recognize the suffix but not remove it. This isn't too important in this simple case of course.
PS. yes, I think it's good perl code, except for the too many empty lines.
|
|---|