use Data::Dumper; my @intf_list = ("xe-1/2/0", "xe-2/2/0", "xf-3/2/a"); foreach my $myint (@intf_list) { my @outputlist = $myint=~/^(\w+)-(\d+)\/(\d+)\/(\d+)$/ or die "Couldn't match \"$myint\""; print Dumper(\@outputlist); } __END__ $VAR1 = ['xe', '1', '2', '0']; $VAR1 = ['xe', '2', '2', '0']; Couldn't match "xf-3/2/a" at - line 4.