http://www.perlmonks.org?node_id=565506


in reply to Re: Using a regex function from a hash
in thread Using a regex function from a hash

EXCELLENT. now a follow up. I am trying to get the word out of a line without much success. Here is some example lines:

Created by GeorgeO at the parker inn
date : 06-Aug-06:22.34.01 buncahstuffIdon'twant
Created by 7of9 at the parker inn
date : 06-Jan-06:22.34.01 buncahstuffIdon'twant
Please get me:
GeorgeO
06-Aug-06:22.34.01
7of9
06-Jan-06:22.34.01

my %functions_hash = ( '^Created by ' => sub { $_[0] =~ /^Created by (\w+)/; $_[0] = $1; }, '^date :' => sub ( $_[0] =~ /^data :(#HELP!!)/; $_[0] = $1 ); ... if ( $data =~ /$key/ ) { $value->( $data ); }