jivanm has asked for the wisdom of the Perl Monks concerning the following question:
I get the error
the corresponding code isCan't use string ("") as a subroutine ref while "strict refs"
if I use a string as the key the code works, how can I expand the regex correctly for the function to use it?my $var1; my $var2; my $regex=qr/^Device(\s)+Configuration/; tie %functions, 'Tie::RegexpHash'; %functions = ( ($regex => \&get_device); my $result = $functions{$var1}->($var2);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using a regex as a hash key
by japhy (Canon) on Jun 06, 2007 at 16:17 UTC | |
Re: Using a regex as a hash key
by ikegami (Patriarch) on Jun 06, 2007 at 17:00 UTC | |
Re: Using a regex as a hash key
by citromatik (Curate) on Jun 06, 2007 at 16:51 UTC | |
Re: Using a regex as a hash key
by halley (Prior) on Jun 06, 2007 at 16:47 UTC | |
by ikegami (Patriarch) on Jun 06, 2007 at 16:57 UTC | |
by halley (Prior) on Jun 06, 2007 at 17:04 UTC | |
by ikegami (Patriarch) on Jun 06, 2007 at 17:12 UTC |
Back to
Seekers of Perl Wisdom