Link to home
Start Free TrialLog in
Avatar of Europa MacDonald
Europa MacDonaldFlag for United Kingdom of Great Britain and Northern Ireland

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/Desktop/Lessons/comp/master.txt") or die "can not open INPUT";
open (MATCH,"<C:/Users/mickg/Desktop/Lessons/comp/match.txt") or die "can not open MATCH";
open (NONMATCH,"<C:/Users/mickg/Desktop/Lessons/comp/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);
ASKER CERTIFIED SOLUTION
Avatar of Dave Cross
Dave Cross
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Europa MacDonald

ASKER

thankyou :)