Problems? Is your data what you think it is? | |
PerlMonks |
Re^5: How to split an integer??by tobyink (Canon) |
on Dec 06, 2012 at 11:40 UTC ( [id://1007540]=note: print w/replies, xml ) | Need Help?? |
Byte?! You're thinking in C terms! Go wash your mouth out with soap right now! ;-) In Perl, strings and integers are both represented by the same data type - scalars. (Internally Perl represents scalars as a C struct which has separate string and integer slots. But you don't normally need to worry about such concerns.) If you have a variable that contains an integer value, such as 23, and pass it to something that expects a string, like split, that integer will be silently converted to a string. Here's exactly the same function I posted before, only now I'm using the integer 23 as the input...
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|