Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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?
[shmem]: moin monkses

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2017-07-25 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (364 votes). Check out past polls.