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
In reply to Re: splitting headache
by Rich36
in thread splitting headache
by Wibble
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |