Europa MacDonald
asked on
Error message : Global symbol %lines
I have the code below, which generates the error message:
#Global symbol "%lines" requires explicit package name at 002comparitor.pl line 20.
Could you explain how I can solve this error please ?
code:
#!usr/bin/perl
use strict;
use warnings;
my $fil = shift; # command line argument is the file to read lines from
open (INPUT,"<C:/Users/mickg/De sktop/Less ons/comp/m aster.txt" ) or die "can not open INPUT";
open (MATCH,"<C:/Users/mickg/De sktop/Less ons/comp/m atch.txt") or die "can not open MATCH";
open (NONMATCH,"<C:/Users/mickg /Desktop/L essons/com p/nonmatch .txt") or die "can not open NONMATCH";
my @lines = map { chomp; $_ } <INPUT>;
while (@lines > 6) {
# check first 5 lines against the 6th line
my @match = grep { $_ eq $lines[5] } @lines[0..4];
my @nomatch = grep {$_ ne $lines[5] } @lines{0..4};
# do whatever you want with the matches and no-matches
print MATCH @match;
# get rid of first line so next loop will be 2-6 and so on
shift @lines;
}
close (INPUT);
close (MATCH);
close (NONMATCH);
#Global symbol "%lines" requires explicit package name at 002comparitor.pl line 20.
Could you explain how I can solve this error please ?
code:
#!usr/bin/perl
use strict;
use warnings;
my $fil = shift; # command line argument is the file to read lines from
open (INPUT,"<C:/Users/mickg/De
open (MATCH,"<C:/Users/mickg/De
open (NONMATCH,"<C:/Users/mickg
my @lines = map { chomp; $_ } <INPUT>;
while (@lines > 6) {
# check first 5 lines against the 6th line
my @match = grep { $_ eq $lines[5] } @lines[0..4];
my @nomatch = grep {$_ ne $lines[5] } @lines{0..4};
# do whatever you want with the matches and no-matches
print MATCH @match;
# get rid of first line so next loop will be 2-6 and so on
shift @lines;
}
close (INPUT);
close (MATCH);
close (NONMATCH);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER