#!/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+\()/ );