You appear to be trying to use the command-line version of grep, rather than a Perl grep. To get what you appear to be looking for in Perl would require opening the file:
Script: grep.pl #!perl -w use strict ; my $fn = "test.txt" ; open(INFILE, $fn) or die "Can't open input file: $fn ($!)" ; my @match_lines = grep /abc|xyz|pqr/i, <INFILE> ; print @match_lines ; print scalar(@match_lines) ; print "Found it!\n" if @match_lines ; close INFILE ; File: test.txt ABC 1121 xyz 2234 pqr this is a test Output: ABC xyz pqr 3 Found it! You should avoid using the backtick operator because it is far slower than the equivalent Perl code. Also, the shell command (in this case grep) might not be implemented the same on all platforms - the command you have listed works on my HP-UX system, but doesn't work on my Win2k or Sun computers. One last thing - you can do far more with Perl's grep than you can with the shell grep. See perldoc -f grep (and map) for more info. Craig Arnold Boeing Space & Comm International Space Station Guidance, Navigation & Control Huntington Beach, CA -----Original Message----- From: AITHA, BHEEMSEN (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 11:23 AM To: '[EMAIL PROTECTED]' Subject: [Perl-unix-users] Please help on GREP command Hi listers, I am using the following command in my perl script. But when I execute the script I am getting the error "Unrecognized file test: -E at test.pl line 9." grep -E -i -c "abc|xyz|pqr" test.txt ; Can someone please tell me what I am doing wrong here ? All I wanted to do is to search for any of the stings abc, xyz or pqr in the file test.txt. Thanx.. -Bheem _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs