Perl: the Markov chain saw | |
PerlMonks |
Re: How do I get the value of a number that belongs to a string??by chromatic (Archbishop) |
on Feb 19, 2000 at 02:07 UTC ( [id://3726]=note: print w/replies, xml ) | Need Help?? |
Perl will automatically do the right thing with a scalar depending on the context in which you use it. If you were to say:
you'll get 3. If you say: you'll get 12 ("2" appended to "1"). To force interpretation in a numeric context, you can try: and you'll get 10. Note that this only works on scalars starting with digits. Strip them out with a regex if you need to.
In Section
Seekers of Perl Wisdom
|
|