Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-12-12 21:08 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (339 votes). Check out past polls.