I can't see my error here Monks!!!
I just need to grep where data from the pattern file exists in the input file.
input.file looks like this :
David@domain.com|David@domain.com|J|ABBASS, DAVID JOHN|
Cory@domain.com|Cory@domain.com|E|ABBOTT, CORY J|
Tania@domain.com|Tania@domain.com|F|ABBOTT, TANIA LEE|
Geoffrey@domain.com|Geoffrey@domain.com|N|ABBOTT, GEOFFREY BRYAN|
pattern.file looks like this :
Randall@domain.com
David@domain.com
Rob@domain.com
Tania@domain.com
Script should tell me that Tania@ and David@ exist :
sub main { my $filename = "input.file"; open (my $valuesFile, '<', 'pattern.file') or die "Failed: $!\n"; while (<$valuesFile>) { push (@lines, $_); } open(INPUT, $filename) or die "Cannot open $filename"; while (<INPUT>) { ($userName,$emailAddress,$division,$fullName) = split(/\|/, $_); while (@lines) { my $pattern = pop @lines; $pattern=~s/\n//g; #print "pattern: ".$pattern."address: ".$emailAddress."\n"; if ($emailAddress =~ /$pattern/) { print $pattern . " exists in " . $emailAddress."\n"; } else { print $pattern . " no match " . $emailAddress."\n"; last; } } } close(INPUT); close $valuesFile; }
In reply to Look for pattern in file. ???? by davidinottawa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |