Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: generating rows(matrix) based on file content

by choroba (Abbot)
on Apr 23, 2013 at 13:17 UTC ( #1030138=note: print w/ replies, xml ) Need Help??


in reply to generating rows(matrix) based on file content

Just go through the input file and assign ones to a new array to given indexes:

while (my $line = <>) { chomp $line; my (@columns) = split ' ', $line; my @switches = (0) x 6; unshift @switches, shift @columns; # runX kept. $switches[$_] = 1 for @columns; print join(' ', @switches), "\n"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: generating rows(matrix) based on file content
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-20 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls