#!/usr/bin/perl use warnings; use strict; print "Write the directory where you want to search: \n"; my $dir=; chomp $dir; print "Write the string you want to search for: \n"; my $string=; chomp $string; opendir DH, "$dir" or die "Couldn't open that directory $dir: $!"; while($_=readdir(DH)){ next if $_ eq "." or $_ eq ".."; if (-d $_){ print "$_ is a directory\n"; next; } open FILE, "$_" or die "Couldn't open that file $_: $!"; for my $i (){ if($i=~/($string)/){ print "I have found |$string| in |$_| file on line:\n$i\n"; last; } } }