Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: String/Numeric Manipulation

by Elgon (Curate)
on Oct 07, 2004 at 18:56 UTC ( #397402=note: print w/replies, xml ) Need Help??


in reply to Re: String/Numeric Manipulation
in thread String/Numeric Manipulation

Random_Walk,

A minor nit. If I've understood the code correctly, you've used a substitution...

$days = s/+//;

...where a transliteration would be "better"...

$days = tr/+//d;    # Note transobliteration modifier

...and a lot faster (not that this is really an issue in this case.)Unless you wanted to allow only a leading + in which case...

$days = s/^+//;

Elgon

It is better wither to be silent, or to say things of more value than silence. Sooner throw a pearl at hazard than an idle or useless word; and do not say a little in many words, but a great deal in a few.

Pythagoras (582 BC - 507 BC)

Replies are listed 'Best First'.
Re^3: String/Numeric Manipulation
by Random_Walk (Prior) on Oct 08, 2004 at 12:05 UTC

    You are right tr would have been more efficient for what I did but I really should have put s/^+//; to follow the principle of least surprise so that 2+3 would be rejected rather than converted to 23

    Cheers,
    R.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://397402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2016-09-24 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (462 votes). Check out past polls.