http://www.perlmonks.org?node_id=1030138


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