Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Using the Substr

by derby (Abbot)
on Mar 04, 2014 at 19:31 UTC ( #1076947=note: print w/replies, xml ) Need Help??


in reply to Re: Using the Substr
in thread Using the Substr

and assuming they're not always digits but a colon is always the separator, a combination of split, array slicing, and join:

$result = join( ':', (split( /:/, $string))[0..2]);

-derby

update: I like hdb's better ... less parens.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-12-06 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?