printf "next is %s\n", next_file($_) for qw( a.png dpq.jpg zx.png ott.jpg zzz.tiff oi.png ); #### sub next_file { ... my @alphabet = qw/a b c d e f g h j k m n p q r s t u v w x y z/; #### { my @alphabet; BEGIN { @alphabet = ('a' .. 'h', 'j', 'k', 'm', 'n', 'p' .. 'z'); } sub next_file { ... } } #### $previous =~ /(.*)\.(.*)/; my $word = $1; my $ext = $2; #### my ($word, $ext) = $previous =~ /(.*)\.(.*)/;