my @intf_list = ("xe-1/2/0", "xe-2/2/0"); foreach my $myint (@intf_list) { my @outputlist = split /-\d+/, $myint; print "$outputlist[1]\n"; }