Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by arturo (Vicar)
on Apr 24, 2001 at 20:59 UTC ( #75138=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I pull n characters off the front of a string? - Answer contributed by arturo

Bah! Why use regexes when there's a faster function designed for the purpose? =)

#assuming $n contains the number ... my $first_n = substr($string, 0, $n); #to grab $n off the end my $last_n = substr($string, -1, $n);

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: Yay, it's Friday! All hail Crunchy!

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2016-12-09 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (148 votes). Check out past polls.