sorry, I forgot to send my mail to the list:
Jeff Pang schrieb: > > then use regex or other ways (I prefer substr) to get the prefix. > > my $prefix = substr($string,1,3); I think the problem is that some countrycodes are only 2 digits some are 3 ( or more ? ) So you dont know how long your prefix is. A further suggestion that extends jeffs idea could be following: you have a longest key in your hash lets say it stored in $prefix_len, so you could do (pseudocode): my $prefix = substr($string,1, $prefex_len); if($prefix eq somekey_of_your_hash){ yay :-) }else{ try it again with substr($string,1, $prefix_len - 1) } HTH Regards Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/