in reply to Re^2: Using pattern match
in thread Using pattern match
Something like this:
#!/usr/bin/perl -w use strict; # builtin triggers my %triggers; # add triggers from params my $trigger_name = shift @ARGV; my $trigger_action_str = shift @ARGV; $triggers{$trigger_name} = $trigger_action_str; my $buff = "You are fired!"; foreach my $trigger ( keys ( %triggers ) ) { if ( $buff =~ /$trigger/ ) { print eval '"' . $triggers{$trigger} . '\n"'; } }
But this is not a design anyone will recommend.
Besides, this will not run in taint mode.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Using pattern match
by tceng (Novice) on Aug 10, 2007 at 14:50 UTC | |
by akho (Hermit) on Aug 10, 2007 at 15:46 UTC |