Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How do I pull n characters off the front of a string?

by xtrem (Novice)
on Apr 24, 2001 at 20:29 UTC ( [id://75128]=note: print w/replies, xml ) Need Help??


in reply to How do I pull n characters off the front of a string?

my ($x,$y) = ($string =~ /^(.{n})(.{n})/);
This will put the 1st n char into $x and the 2nd n chars into $y without touching $string... if you want the rest of the chars:
my ($x, $y, $rest) = ($string =~ /^(.{n})(.{n})(.*)/);
if you don't like regexp's you can allways try substr

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-16 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found