Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: generating rows(matrix) based on file content

by choroba (Chancellor)
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"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

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 rifling through the Monastery: (5)
As of 2016-09-30 22:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (574 votes). Check out past polls.