15
It is my first day to perl, and I find this warning very confusing.
Parentheses missing around "my" list at ./grep.pl line 10.
It seems
open FILE, $file;
works fine.
What is wrong with
open my $fh, $file;
Thanks!
#!/usr/bin/perl
use strict;
use warnings;
sub grep_all {
my $pattern = shift;
while (my $file = shift) {
open my $fh, $file;
while (my $line = <$fh>) {
if ($line =~ m/$pattern/) {
print $line;
}
}
}
}
grep_all @ARGV;