Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: change [A-Z] to U, [a-z] to L with one regex?

by punch_card_don (Curate)
on Mar 19, 2013 at 12:10 UTC ( #1024281=note: print w/replies, xml ) Need Help??

in reply to change [A-Z] to U, [a-z] to L with one regex?

It may be useful to stop and ask why one would want to do that. Is there some compelling practical reason? Sometimes we just get caught up in the mindset that it's more elegant to condense as much as possible, but it's not always. The original code
$r =~ s/[A-Z]/U/g; $r =~ s/[a-z]/L/g;
is so crystal clear and simple. It's probably pretty darn efficient too. Why garble it up just to save a line?

Time flies like an arrow. Fruit flies like a banana.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024281]
[M4ver1k]: I feel like being able to toggle a running script on the fly by updating variables from a config file using Config::Simple. But in the while loop, it seems like it doesn't update the variable after the first past. Is this generally just a bad idea?
[M4ver1k]: pass*

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2017-11-20 03:09 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (283 votes). Check out past polls.