in reply to splitting headache
To use split, you can reverse the string with the names, only split enough times (6) so that the last string contains the '.', reverse the order of the elements in the foreach loop, then (un)reverse the string when you print it.
my @names = split(/\./, reverse("Pugh.Pugh.Barney.McGrew.Cuthbert.Dibb +le.Grub"), 6); foreach(reverse(@names)) {print reverse . "\n";} __RESULT__ Pugh.Pugh Barney McGrew Cuthbert Dibble Grub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: splitting headache
by Wibble (Beadle) on Feb 26, 2002 at 14:43 UTC |