in reply to Parse a line

I don't think that script applies to your problem. There are likely a thousand ways of doing what you want, but this works:
#!/usr/bin/perl use strict; use warnings; my $line = 'sample/fresh/fresh/0/pineapple'; my @words = split/\//, $line; print $words[-1],$/;
Look at perldoc -f split