#!/usr/bin/perl use strict; use warnings; print "Enter the filename to be parsed\n"; my $fileName = ; print "Enter the keyword to be searched in the file\n"; my $keyword = ; chomp $fileName; chomp $keyword; open my $inFile, '<', $fileName or die "Failed to open $fileName: $!\n"; # Search for the key pattern in the file information. while (defined (my $line = <$inFile>)) { chomp $line; next if $line ne $keyword; print "Found key word $keyword on line $.\n"; exit; } print "Keyword not found\n";