[Chicago-talk] Using a hash in a regex

Jay Strauss me at heyjay.com
Thu Jul 13 13:32:04 PDT 2006


Hi,

How do you use a hash in a regex?  I remember it being mentioned but I
couldn't find it in the archives.  For example,

%h = (this=>1, that=>2);

$s = "this is a test";

# now what I'd like to do is:
my $n = m/$s/%h/;  #and have $n = 1;

I can't google how to do it. I know I could loop thru the hash (like I'm
doing now) but I could have sworn I could use it in the regex.

Thanks
Jay



More information about the Chicago-talk mailing list