in reply to Re^3: Comparing pattern
in thread Comparing pattern
Test list with patterns:#!/usr/bin/perl -w use strict; my $patterns = "/path/to/patterns.txt"; my $arg1 = shift; open (PAT, '<', $patterns) or die "$patterns: $!\n"; my @patterns = <PAT>;. close(PAT); chomp @patterns; my $regex_string = join '|', @patterns; open( FILE, "<", "$arg1") or die "$arg1: $!\n"; $_ = do { local $/; <FILE> }; close(FILE); if ( /($regex_string)/is ) {print "\n$arg1\n$1\n";}
Test file to scan:part1.*part2 Foo bar Other pattern
$1 will show all wildcarded text between part1 and part2 and not only the pattern part1.*part2 as it should.hghghgghghh part1 fff part2 jhhjhjkjk Foo bar kkjkjkj Other pattern
/path/to/file part1 fff part2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Comparing pattern
by graff (Chancellor) on Sep 22, 2009 at 00:32 UTC |