Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: making presence/absence table from a hash of arrays

by Anonymous Monk
on Sep 06, 2011 at 09:39 UTC ( #924343=note: print w/replies, xml ) Need Help??


in reply to making presence/absence table from a hash of arrays

You clearly want to use a regular expression:

#!/ichigo/perl use v5.12; use warnings; use strict; my @array = qw/ one two three four five /; my %hash = ( row_1 => [ qw/ one five two / ], row_2 => [ qw/ four two / ], row_3 => [ qw/ three one five four / ], ); my $row = "@array"; say $row; for my $key (sort keys %hash) { my $re = join '|', @{$hash{$key}}; say "$key = ", grep s/\b($re)\b|\w+/$#-/g, "$row"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924343]
help
Chatterbox?
NodeReaper wonders through a maze of twisty little sayings, all different

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-09-21 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (242 votes). Check out past polls.

    Notices?