Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: How can you check if a word in a array occur in another array?

by tobyink (Abbot)
on Nov 29, 2012 at 08:49 UTC ( #1006199=note: print w/replies, xml ) Need Help??

in reply to How can you check if a word in a array occur in another array?

This line:

@words = split(/ /, $word);

... replaces the @words array each time around the loop. So when you're finished looping, @words will only contain words from the last line of the file, words from the previous lines having been discarded.

What you want is:

push @words, split(/ /, $word);

I leave @EN = split(/ /, $word) as an exercise for the reader.

Also, I concur with frozenwithjoy in that a hash is more likely to suit your needs than an array.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2016-10-28 23:12 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (387 votes). Check out past polls.