On Dec 31, 2007 4:29 PM, Jeremy Kister <[EMAIL PROTECTED]> wrote:
snip
> if($string =~ /$regex/$modifier){
snip

Use the embedded pattern-match modifier.  See perldoc perlre or
http://perldoc.perl.org/perlre.html#'(%3fpimsx-imsx)' for more
information.

#!/usr/bin/perl

use strict;
use warnings;

my $modifier = "i";
my $regex = qr/(?$modifier)word/;

my @strings= qw<word Word WORD false>;

for my $string (@strings) {
        if ($string =~ /$regex/) {
                print "$string matched\n";
        } else {
                print "$string did not match\n";
        }
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to