in reply to Re: Re: Best way to match items in an array
in thread Best way to match items in an array

It is not required to have unique handler for each suffix. As the suffixes are just 'values' of the hash, not 'keys', so you can share handlers among suffixes. Also, you can make those handlers accept more parameters, for complex situation.
  • Comment on Re: Re: Re: Best way to match items in an array

Replies are listed 'Best First'.
Re: Re: Re: Re: Best way to match items in an array
by ibanix (Hermit) on Dec 07, 2002 at 21:23 UTC
    Actually, I was thinking that I would have to code something like:

    my %handlers = ("zip" => \&zip, "zaaap" => undef, "txt" => \&txt, "ini +" => \&misc, "foo" => \&misc, ....);
    That is, if I have 50 different file types, do I need 50 different "end" => \&handler entries?

    In addition, my suffixes may not be known until the script is run...

    $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;