Re: hellp improve efficiency



On 4/28/07, Jen mlists <practicalperl@xxxxxxxxx> wrote:

}elsif ($uri =~ m|www\.example\.com/v2/|o) {
$uri =~ s|www\.example\.com/v2/|v2.example.com/|;

The /o modifier isn't desirable there. Also, because a s/// will only
replace if the match part succeeds, you can skip the test:

$uri =~ s#www\.example\.com/v2/#v2.example.com/#;

If it matters to you whether the pattern matched or not, you may test
the result in a scalar context:

} elsif ($uri =~ s#www\.example\.com/v2/#v2.example.com/#) {
# substitution succeeded, do nothing further
} elsif (...) {

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
.