Hello Monks, I need help understanding how to format some text. I opted for an array since I do not know how to add multiple values to key in a hash. Clearly, I do not understand how to manipulate the array of elements to create a table equally align.
desired output, name of probe on the left side then all (x,y) coords and units on the right:
MM_STD_gate -61.771653 -45.472441 mils + -1569.000000 -1155.000000 micro +ns RFN_a -91.102362 68.307087 mils + -2314.000000 1735.000000 micro +ns RFN_b -62.165354 68.307087 mils + -1579.000000 1735.000000 micron +s RFN_c -51.417322 68.307087 mils + -1306.000000 1735.000000 micro +ns
#!/usr/bin/perl #use strict; use warnings; use Data::Dumper; my @records; my @col; my ($probe, $x_coord, $y_coord, $mils, $micron); my $infile= 'coord.txt'; open (DATA,'<',$infile) or die "could not open the $infile: $!"; while (<DATA>) { chomp; my @col = split " ", $_; push @records, \@col; } #print Dumper(\@col, @records); for (\@col){ print join("\t",$col{$records[0]}, $col{$records[1]}, $col{$record +s[2]}, $col{$records[3]}); } #this for loop doesn't work
DATA can be presented in unalign format
__DATA__ MM_STD_gate -61.771653 -45.472441 mils -1569.000000 -1155.000000 microns RFN_a -91.102362 68.307087 mils + -2314.000000 1735.000000 microns RFN_b -62.165354 68.307087 mils + -1579.000000 1735.000000 microns RFN_c -51.417322 68.307087 mils + -1306.000000 1735.000000 + microns
In reply to Help with Creating a Table from array ref I parsed in by perlynewby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |