If I try to run this:#!/usr/bin/perl -w # builtin triggers my %triggers; # add triggers from params my $trigger_name = shift @ARGV; my $trigger_action_str = shift @ARGV; my $trigger_action = sub { $trigger_action_str }; $triggers{$trigger_name} = $trigger_action; #print "$trigger_name -> $trigger_action_str\n"; my $buff = "You are fired!"; foreach my $trigger ( keys ( %triggers ) ) { if ( $buff =~ /$trigger/ ) { #print "Memory contents of \$1: $1\n"; print &{$triggers{$trigger}}; } } print "\n";
In reply to Re^2: Using pattern match
by tceng
in thread Using pattern match
by tceng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |