in reply to Nested foreach

Lowercasing each line is simple. $line = lc $line; tr/// works fine, too.

Put your ignore words in a hash, like so:

my %ignores = map { $_ => 1 } qw/bar foo baz quux/;

Then, as you read through the file break your $lines into $word's and:

next if $ignores{$word};

Hashes are fast and convenient. Use them.

--
perl: code of the samurai

Replies are listed 'Best First'.
Re: Re: Nested foreach
by dragonchild (Archbishop) on Apr 25, 2003 at 16:54 UTC
    Lowercasing each line is simple. $line = lc $line; tr/// works fine, too.

    Functionally, yes. But, lc is self-commenting. tr is not. Use the self-commenting one.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.