There's more than one way to do things | |
PerlMonks |
Re: How do I pull n characters off the front of a string?by davido (Cardinal) |
on Oct 03, 2003 at 01:31 UTC ( [id://296137]=note: print w/replies, xml ) | Need Help?? |
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):
In Section
Seekers of Perl Wisdom
|
|