#!/usr/bin/perl -wl use strict; for (){ chomp; my ($base, $end) = $_ =~ /(\w+)\.(tif(?:f)?\b)/gi; next if not defined $base; print "$base \t $end"; } __DATA__ list 1.tif convert 3.tif to baloney.pic path is c:\TIFS\009.tif 10.tif how many "11.tifs" are there? 14.TIFF