#!/usr/bin/perl use strict; use warnings; use File::Find; my $dir = '/home/me/Desktop/tasks/Korpora/'; my $string = 'Alice '; open my $results, '>', '/home/me/Desktop/results.txt' or die "Unable to open results file: $!"; find(\&printFile, $dir); sub printFile { return unless -f and /\.html$/; open my $fh, '<',, $_ or do { warn qq(Unable to open "$File::Find::name" for reading: $!); return; }; while (<$fh>) { if (/\Q$string/) { print $results "$File::Find::name\n"; return; } } }