Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: More Help with Regex

by impossiblerobot (Deacon)
on Jan 31, 2002 at 20:32 UTC ( [id://142501]=note: print w/replies, xml ) Need Help??


in reply to More Help with Regex

If you know the length of the string, you can use unpack:
print join(':', unpack 'a2a2a2a2a2a2', '00a0c801adc6')),"\n<BR>";
In fact, even if you don't, you could probably do something like this:
my $string = '00a0c801adc6'; print join(':', unpack('a2' x (length($string)/2), $string)),"\n<BR>";
(Documentation on using unpack seems unusually sparse, so there might be an easier way to do this that I am unaware of.)

Also ++petral. I knew there had to be a way to use split and extended patterns, but couldn't work it out myself.

Impossible Robot

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found