At this point it's pretty obvious that this is just a series of exercises for which you are asking for an answer. Beyond the fact that perlmonks is not a code writing service (you can't rely on being given a full answer, because perlmonks is more about giving means and corrections, not the full solution), this means that there's a chance that you are expected to explore or demonstrate a specific tool or idiom of perl. But (one of) perl's motto is "There is more than one way to do it", so even if you get *a* solution, it might not be the expected one, and you probably won't have learned what you were meant to learn.
For example in this case, this might be an exercise meant to demonstrate the use of slices, or split, or while with last... (there are plenty of other tools that could be used, but these are the most straightforward for your problem IMHO). It might even be about oneliners, in which case there's a very high chance that you'll just be given a solution that's completely out of topic.