Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Using the Substr

by derby (Abbot)
on Mar 04, 2014 at 19:31 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-29 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found