>>>>> "SB" == Steve Bertrand <st...@ipv6canada.com> writes:
SB> use Tie::RegexpHash; SB> my $number = qr/^\d+$/; SB> my $alpha = qr/^\w+$/; SB> tie my %dt, 'Tie::RegexpHash'; that sounds like an insane idea for a module. but that is IMO. you can do this with much less effort with a list of regexes paired with code refs. and if that fails or you can control the order, you can then try a regular dispatch table. there is no way this module can do anything else but a linear search through all the regexes and then it won't allow ordering which can be very important. this is too easy to roll your own and you get better control from doing that. two strikes against it. SB> %dt = ( SB> common => sub { SB> my $param = shift; SB> print "$param\n"; SB> }, SB> $number => sub { SB> return int( rand( 3 ) +1 ); SB> }, SB> $alpha => sub { SB> my @letters = ('a'..'z'); SB> return $letters[ rand scalar @letters ]; SB> }, SB> run => \&run, SB> ); SB> sub run { SB> my $param = shift; SB> $dt{ common }( $param ) ; that is the bug. all code refs need to be called either with & prefix or by ->(). you have neither. $dt{ common }->( $param ) ; uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/