in reply to Re: How to take the last character out of a string
in thread How to take the last character out of a string
No doubt, this works. But it's doing a lot of work it doesn't need to.
For the first one, just get rid of the (.*) and $1: $query1 =~ s#,$##gs. For the second, just add an appropriate plus sign: $query =~ s#,+$##s. For the last, well, just remove the ending s - it's not doing anything: $query =~ s#,+$##.
"Premature optimisation is the root of all evil." Well, I'm not optimising - I'm merely encouraging idiomatic use of perl: writing perl the way it should be. Minimally, but not unreadably. (The last part doesn't apply to obfu's and golf competitions.)
|
|---|