Next | Program Repair Shop | 202 |
It's a little easier to understand in the reverse direction:
Subject: Problem for uploading a file Message-Id: <UCWz4.3319$Fk3.169728@weber.videotron.net>
if ($File_Handle =~ /([^\/\\]+)$/) { } else { print p("Bad filename... check for forward or back slashes\n"); }
The no-brain transformation in such circumstances is to use if (not...) or unless:
unless ($File_Handle =~ /([^\/\\]+)$/) { print p("Bad filename... check for forward or back slashes\n"); }
This already eliminates the phantom block
But sometimes the condition itself is already negated!
if ($File_Handle =~ m{[/\\]$}) { print p("Bad filename... check for forward or back slashes\n"); }
Watch out for ^ in character classes and for !~
Next | Copyright © 2002 M. J. Dominus |