$ perl -le 'print +(split /\//)[-1] for ("/ba/mn/first one", "/ba/mn/second")' first one second