You need to show the actual code you tried. Much, much better is to rework your code into a stand alone test script so we can run exactly what you are running with the same data. Something like:
#!/usr/bin/perl use strict; use warnings; my $keyword = 'file'; # Search for the key pattern in the file information. while (defined (my $line = <DATA>)) { next if $line !~ /\b\Q$keyword\E\b/; print "Found key word $keyword on line $.\n"; exit; } print "Keyword not found\n"; __DATA__ Hi, I am a newbie to perl. I am trying to pass the filename and search + for a keyword in that file and if found print that line else print not found + message. However though my file has the keyword I get not found message.Please +help.I
Prints:
Found key word file on line 2
In reply to Re^3: Error using grep
by GrandFather
in thread Error using grep
by justkar4u
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |