#!/usr/bin/perl -w use strict; foreach my $lastone (){ if ($lastone =~ m{/[-\w]+$} && $lastone !~ m{/\d$}){ print $lastone; } } __END__ hull/uuu/8 cook/too/un-8-9 luck/goo@@ luck/goo yty~uyuoo~iu99~##uyt~hu/dwo9 chuck/ii@@/a_