in reply to Re: generating rows(matrix) based on file content
in thread generating rows(matrix) based on file content
...and one version based on regex if the number of switches is known:
use strict; use warnings; my $n_switches = 6; while(<DATA>){ my $last = 0; s/\s(\d+)/my $d = $1-$last-1; $last = $1; " 0"x$d." 1" /ge; s/\n/" 0" x ($n_switches-$last)."\n"/e; print; } __DATA__ run1 2 4 run2 1 6 run3 1 run4 1 3 run5 2 5
|
|---|