On 2010.04.29 23:23, Uri Guttman wrote:
>>>>>> "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.

It's not my module. An example of what you just described would be most
appreciated ;)

>   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 ) ;

I swear I tried that. I'm obviously missing something. Why is the
following code working without the prefix, or the ->. Am I wrong in
thinking that what I'm doing below is a coderef?:

#!/usr/bin/perl

use warnings;
use strict;

my %dt = (
        a => sub {
                my $in = shift;
                print "allo, $in\n"
            },
        );

$dt{ a }( 'uri' );

__END__

Thanks Uri, as always,

Steve

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to