in reply to Using pattern match
May be I am missing something obvious, but wouldn't a simple printf work ? (assuming there is only one variable needed).
Something like that :
#!/usr/bin/perl -w my %triggers = ( 'You are (\\w+).' => 'Your status is: %s', ); my $buff = "You are fired!"; foreach my $trigger ( keys ( %triggers ) ) { if ( $buff =~ /$trigger/ ) { print sprintf( $triggers{$trigger}, $1); } } print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using pattern match
by Anonymous Monk on Aug 10, 2007 at 18:05 UTC | |
by tceng (Novice) on Aug 10, 2007 at 18:30 UTC | |
by mreece (Friar) on Aug 11, 2007 at 05:50 UTC | |
by tceng (Novice) on Aug 11, 2007 at 22:08 UTC |