#!/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";
In reply to Re: Using pattern match
by akho
in thread Using pattern match
by tceng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |