Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl -w use strict; use warnings; my @grep_includes=( "./data/basic-socket-test/basic-socket-test.cpp:#include \"AEEatomic.h +\"" ); my @headers=("AEEatomic.h"); my %seen; my ($header_file,$original_line,@header_present,$only_include,$header_ +notfound,@notinformat,@casesensitives); foreach my $line (@headers) { #print "Headerfile is: $line\n"; @header_present = grep (/^\Q$line\E$/i, @grep_includes); #print "HEADER_PRESENT:@header_present\n"; if(@header_present) { #check if the header file matches @headers array + print "HEADER FILE:$line\n"; } else { #print "HEADER FILE NOT PRESENT:$line\n"; } @header_present=''; }#end of for loop

Replies are listed 'Best First'.
Re: Why is the grep failing?
by ikegami (Patriarch) on Apr 08, 2011 at 00:38 UTC

    Case aside, there's only two possible strings it can match:

    AEEatomic.h AEEatomic.h<LF>
    The string you tried to match
    ./data/basic-socket-test/basic-socket-test.cpp:#include "AEEatomic.h"
    is neither. Perhaps you wanted
    /\Q$line\E/i