in reply to Using pattern match
#!/usr/bin/perl -w use strict; my %triggers = ( 'You are (\\w+).' => sub { "Your status is: $1" }, ); 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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using pattern match
by tceng (Novice) on Aug 10, 2007 at 11:23 UTC |