in reply to Searching a collection of signatures

Nice, though I do have a few suggestions about this line:
map {chop} @sigs;
First of all, its always safer to use chomp, since it will only remove whatever your OS uses for newlines. If there isn't a newline after the last sig in your file, your chop version will remove the last char in the sig, chomp wont.
map {chomp} @sigs;
Second we're calling map in void context which is expensive. map generates a new array for us, that we don't need or use -- i.e. @newarray = map {chomp} @sigs; Such "void maps" are better written as for loops...
chomp for @sigs;
But as it turns out, chomp can take a list as an argument, so the above line can be shortened to:
chomp @sigs;

-Blake

Replies are listed 'Best First'.
Re(2): Searching a collection of signatures
by FoxtrotUniform (Prior) on Nov 07, 2001 at 11:58 UTC

    In fact, I tried chomp first, because I'm not trying to remove newlines, just trailing %s, which chop will happily eat. That said, I can probably just

    s/%$//m for @sigs;
    or some such instead.

    --
    :wq
      After rereading the chomp docs, I realized that chomp will behave like the above regex when $/ is set to '%'...
      # One way.... { local $/ = '%'; chomp @sigs; # chomp uses the value of $/ to figure out what to rem +ove } # or another s/%$// for @sigs;

      -Blake