knudsj01 has asked for the wisdom of the Perl Monks concerning the following question:
When I run this perl script I get the following:#!/usr/local/bin/perl use strict; use warnings; my $contents =<<EOT; #################### # GEOGRAPHY CONFIG # #################### environment.type = eu deployment.type = au EOT #--------------------------------------------------------------------- +--------- # Check that the properties deployment.type and environment.type exist #--------------------------------------------------------------------- +--------- if ( $contents !~ /deployment.type/gm ) { print "ERROR: deployment.type not found in contents\n"; } else { print "deployment.type matched\n"; } if ( $contents !~ /environment.type/gm ) { print "ERROR: environment.type not found in contents\n"; } else { print "environment.type matched\n"; }
One thing I have noticed is if I flip the two pattern searches around (search for environment.type first and deployment.type 2nd, like they exist in $contents) it finds both patterns. But if the pattern searches are reveresed in order from the way they appear in $contents the 2nd pattern match fails.C:\test>perl test.pl deployment.type matched ERROR: environment.type not found in contents
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with 2nd string match in file using regex with gm operators
by ikegami (Patriarch) on Jun 03, 2009 at 20:42 UTC | |
|
Re: Problem with 2nd string match in file using regex with gm operators
by shmem (Chancellor) on Jun 03, 2009 at 23:18 UTC |