in reply to Splitting a word
In the spirit of even more TIMTOWTDI, here's the solution for unpack(), which is another good trick to have in your bag :
Read in the manpage about how unpack() can help you to unpack structured data. Sometimes this is faster than using a regular expression, sometimes it is slower.$a = "de0400Newark"; print join( ",", unpack( "a2a4a*", $a ));
I just noticed that you only want the number instead of all that data. So here's the code which will give you the number :
$a = "de0400Newark"; print( (unpack( "a2a4a*", $a ))[1] );
|
|---|