#!/usr/bin/perl use strict; use warnings; my $count = 1; open( FILE, $ARGV[0] ); while ( my $w = ) { foreach ( $w =~ m/photo\/([a-zA-Z]+\.[a-zA-Z]{3})/g ) { print "Photo: $count $1\n"; $count++; } } $count = $count - 1; print "\nI counted $count image-files\n";