Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: generating rows(matrix) based on file content

by blue_cowdawg (Monsignor)
on Apr 23, 2013 at 13:16 UTC ( #1030137=note: print w/ replies, xml ) Need Help??


in reply to generating rows(matrix) based on file content

      What I want to generate is this. (I also need to keep the row descriptors : run1, run2 etc)

There are many ways to skin this cat and the cat isn't happy about it.

#!/usr/bin/perl -w use strict; while (my $line=<DATA>){ chomp $line; my($run,@sw)=split(/[\s]+/,$line); my @switches=(); $switches[$_] = 0 foreach (0..5); # initialize switch array $switches[$_ -1]=1 foreach (@sw); printf "%s %s\n",$run,join(" ",@switches); } exit(0); __END__ run1 2 4 run2 1 6 run3 1 run4 1 3 run5 2 5


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg


Comment on Re: generating rows(matrix) based on file content
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2015-07-31 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls