in reply to Re^3: Using pattern match
in thread Using pattern match
Yes, that's not elegant for I should save each memory container $1, $2, and so on to be general enough, but at least I can run it in tainted mode:#!/usr/bin/perl -w -T 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/ ) { my $c1 = $1; my $txt = $triggers{$trigger}; $txt =~ s/\$1/$c1/g; print $txt; } }
|
|---|