|
|
| Keep It Simple, Stupid | |
| PerlMonks |
Answer: How do I pull n characters off the front of a string? |
| ( #296137=categorized answer: print w/ replies, xml ) | Need Help?? |
|
Q&A > strings > How do I pull n characters off the front of a string? contributed by davido
The other examples all handed off the first $n characters. But they didn't remove those first $n characters from the original $string, as the question required.
As always, there is more than one way to do it. For each of the examples below, assume the following setup:
With substr:
Another with substr:
And probaby the best substr solution:
With a substitution s/// regexp:
With split:
With a pattern match (m//):
With unpack (Not for the faint of heart):
|
|
||||||||||||||||||||