#!/usr/bin/perl -w
use strict;
my @strings = ( "Foo::Bar()",
"Foo::Bar ()",
"Foo::Bar ()",
" Foo::Bar()",
" Foo::Bar ()"
);
my %test = ( 1 => qr/Foo::Bar(?!\s*\()/,
2 => qr/Foo::Bar(?!\s+\()/
);
####
foreach my $teststring ( @strings )
{
print( "---$teststring---\n" );
foreach my $testnum ( sort { $a <=> $b } keys %test )
{
if ( $teststring =~ m/$test{$testnum}/ )
{
print( "test $testnum matches\n" );
}
else
{
print( "test $testnum does not match\n" );
}
}
}
##
##
---Foo::Bar()---
test 1 does not match
test 2 matches
---Foo::Bar ()---
test 1 does not match
test 2 does not match
---Foo::Bar ()---
test 1 does not match
test 2 does not match
--- Foo::Bar()---
test 1 does not match
test 2 matches
--- Foo::Bar ()---
test 1 does not match
test 2 does not match