How can I implement Unix grep in Perl?
- by Ankit Rathod
How can I implement grep of Unix in Perl? I tried to use Perl's built-in grep. Here is the code which is not working:
$pattern = @ARGV[0];
$file= @ARGV[1];
open($fp,$file);
@arr = <$fp>;
@lines = grep $pattern, @arr;
close($fp);
print @lines;
And by the way, i am trying only basic grep functionality not full featured and secondly i don't want to do string parsing myself. I want to use inbuilt grep or some function of Perl.
Thanks in advance :)