Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Array Comparison

by Not_a_Number (Prior)
on Dec 22, 2003 at 20:11 UTC ( [id://316467]=note: print w/replies, xml ) Need Help??


in reply to Array Comparison

To solve your case problem, try this:

use strict; use warnings; my @words = qw ( a ants cats cats dogs DOGS rabbits r@bbits turtles wa +rthogs ); my @exclude = qw ( ants Turtles WARTHOGS ); my %exclude = map { lc $_ => '1' } @exclude; for ( @words ) { next if /\W/ or length $_ < 4 or $exclude{lc $_}++; print "$_\n"; }

dave

Replies are listed 'Best First'.
Re: Re: Array Comparison
by mcogan1966 (Monk) on Dec 23, 2003 at 20:09 UTC
    Actually, @words and @exclude are generated by reading outside sources. I just dropped the lc() right where the data is being read and it works just fine. Thank you for the suggestion though.
      Actually, @words and @exclude are generated by reading outside sources.

      Well, yeah, that's what I assumed. I just added those arrays for testing. I even assumed that you might not have any control over the 'outside sources', which is why I did the lc() stuff in my snippet :-)

      dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found