$checkfile = "back-20.bak"; $direcory ="/sapp/backup"; $contcheck = "Backup taken for this file"; $telnet->cmd("opendir dhandle,$directory"); @dots = $telnet->cmd("grep { /^$checkfile/ } readdir(dhandle)"); print"Files=> @dots\n"; foreach $filename (@dots) { chomp($filename); @filecont = $telnet->cmd("grep -i $contcheck"); foreach $line (@filecont) { if($line =~ /$contcheck/){ $status = 'FAIL'; }else{ $status ='PASS'; } } }