justkar4u has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl # main program; print "Enter the filename to be parsed\n"; my $file = <STDIN>; open (FILE,$file); @lines = <FILE>; close (FILE); print "Enter the keyword to be searched in the file\n"; chop (my $key = <STDIN>); if (grep {$_ eq $key} @lines) # Search for the key pattern in +the file information. { print "$_ \n"; # If found print the line } else { print "Keyword not found\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error using grep
by GrandFather (Saint) on Mar 29, 2011 at 00:43 UTC | |
by justkar4u (Novice) on Mar 29, 2011 at 02:16 UTC | |
by GrandFather (Saint) on Mar 29, 2011 at 03:09 UTC | |
by justkar4u (Novice) on Mar 29, 2011 at 18:13 UTC | |
by GrandFather (Saint) on Mar 29, 2011 at 20:06 UTC | |
| |
|
Re: Error using grep
by choroba (Cardinal) on Mar 28, 2011 at 23:54 UTC | |
|
Re: Error using grep
by wind (Priest) on Mar 28, 2011 at 23:59 UTC |