Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: generating rows(matrix) based on file content

by hdb (Monsignor)
on Apr 23, 2013 at 20:41 UTC ( [id://1030235]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found