in reply to Regexp and object's methods.

#--- complex.pm package complex; use strict; sub whatis{ my $self = shift; my $input = shift; my %data = ( ip_address => \qr/\d+\.\d+\.\d+\.\d+/, phone => \qr/^\d{3}[-]\d{3}[-]\d{4}$/, ); foreach(keys %data){ return $data{$_} if /$input/; } return 0; } 1; #--- test.pl #!/perl/bin/perl use complex; use strict; my @list1 = qw ( 704-123-4569 115.43.2.123 112.32.24.2 ); push @list1, "312-231-2312 (ext. 23)"; my @list2 = qw ( ip_address phone ); foreach (@list1){ foreach my $x (@list2){ if ( /${complex->whatis($x)}/ ){ print "$_ is an $x\n"; } } if ( /${complex->whatis('phone')}*\s+\(ext\. (\d+)\)/ ){ print "$_ is an phone with ext $1 \n"; } }
Don't know if this helps... return a ref to your objects variable? then de-ref it in your regex and append any additonal expressions? (In this example, I use qr to in the hash, and pass a ref back... I think I can see why you would do this... interesting..)

James :)