in reply to text string approxiamtions (concept for review)
A cool thing that hashes do not do, would be to allow a regex for a key.
I can't speak for earlier versions, but you can definitely use regexes as hash keys in 5.6.1:
use strict; my %tests = ( qr/^[0-9]+$/ => 'positive integer', qr/co/i => 'company/corporation', ); foreach my $term qw(12345 Company Jones) { foreach my $key (keys %tests) { print "$term is a $tests{$key}\n" if $term =~ $key; } }
$perlmonks{seattlejohn} = 'John Clyman';
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: text string approxiamtions (concept for review)
by shemp (Deacon) on Dec 05, 2002 at 16:46 UTC | |
by seattlejohn (Deacon) on Dec 05, 2002 at 19:14 UTC | |
by shemp (Deacon) on Dec 05, 2002 at 22:58 UTC |