in reply to Regular expressions Containing Octal values?

How about another approach altogether? Try a hash with all the different names as keys and a reference to some canonical name or data table row as value.

my $foostuff = '2-Amino-4-hydroxybutyric acid'; my $barstuff = 'ethanol'; my %substances = ( 'L-homoserine' => \$foostuff, 'L-Homoserine' => \$foostuff, 'beer' => \$barstuff, );

I think that will be much simpler to deal with than a similar number of regexen.

By the way, you don't need to deal with numbers as ascii values, numeral strings are fine.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Regular expressions Containing Octal values?
by mephit (Scribe) on May 17, 2002 at 20:16 UTC
    One good thing about this hash approach is that, when you want to "rebuild" with the original names, you can just reverse the hash to build the "reverse lookup table."
    %reverse_hash = reverse %hash;
    This won't work if the values in the original hash aren't unique, of course. (I don't know chemistry, so I don't know if that's the case). Plus, you'd probably need to use actual strings as values for the original hash, as well.

    --

    Mephit (See my home node for my rant about Opera and PerlMonks, and my earliest nodes.