#!/usr/bin/perl use warnings; # This is the directory we will be working with $dir = '.'; # Open it and read all the files contained within opendir DIR, $dir or die "Cannot open $dir: $!\n"; # Cycle through each entry in the directory foreach $file (readdir DIR) { # Make a full path name for the file # Remember that Perl searches the current working directory for a relative file name # The slash below may need to be modified for your OS (this will work on Mac OSX and Unix) # To run this on windows you will need to replace it with '\\' $full_file_name = $dir . '/' . $file; # Only search through text files if (-T $full_file_name) { open FILE, "<$full_file_name" or die "Can't open $file for reading: $!\n"; $line_num = 0; while ($line = ) { $line_num++; # Get all characters between a pair of quotes # Notice the second conditional sets $line to the rest of the sting after match # so that we can find multiple sets of quotes within the same line while (($line =~ /"(.*?)"/s) && ($line = $' )) { print "$file: $line_num - $1\n"; } } close FILE; } } close DIR;