Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: two dimensional array lookup

by tos (Deacon)
on Jul 17, 2003 at 13:55 UTC ( #275215=note: print w/replies, xml ) Need Help??


in reply to two dimensional array lookup

when i saw simonms great solution i was ashamed of my own. But since it was a little trouble for me and because of TMTOWTDI here my approach.

use strict; use warnings; use Data::Dumper; my @erg; my @all=(["what", "is", "the", "matrix"],["matrix", "reloaded", "is", +"no", "good"]); print "\n",Dumper(\@all); for (my $i = 0; $i < @{$all[0]}; $i++) { for (my $j = 0; $j < @{$all[1]}; $j++) { $erg[0][$i] ||= sprintf "%u", ($all[0][$i] eq $all[1][$j]); $erg[1][$j] ||= sprintf "%u", ($all[0][$i] eq $all[1][$j]); } } print "\n",Dumper(\@erg);
greetings, tos

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2021-01-25 18:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?