I need to copy the section heading, paste it at the end of line effectively creating a new column and repeat until the heading changes. I also must capture the header from the top of the file as well, Note that there is nothing beneath the third line. I tried to remove the headings after the copy by removing lines not starting a number, but that deleted the third line and others similar to it. There are many other problems with my code, but I can live with any quirk other than invalid data. As it stands now, some sections of data are landing in the wrong columns, but not all. Column $pn seems to drop in the middle of $line, but only for some headings.FUNCTION VCC= 4.50V, VIL=0V, VIH=3V, VOL=VOH=1.5V PASS 4 730 0 + FUNCTION VCC= 5.50V, VIL=0V, VIH=3V, VOL=VOH=1.5V PASS VOL TEST @VCC= 4.5V, VIL=2V, VIH=5.5V 5 796 6 421.5 mV,RNG1 60.00 mA,M100 + 5 801 381.5 m 0 500.0 m + 5 815 8 417.0 mV,RNG1 60.00 mA,M100 + 5 820 377.0 m 0 500.0 m + VOH1 TEST @VCC=4.5V, VIL=0.8V, VIH=5.5V 6 886 6 2.920 V,RNG2 -3.015 mA,M100 2.500 V 4.500 V + 6 899 6 2.920 V,RNG2 -3.015 mA,M100 2.500 V 4.500 V + 6 912 6 2.916 V,RNG2 -3.015 mA,M100 2.500 V 4.500 V + 6 925 6 2.916 V,RNG2 -3.015 mA,M100 2.500 V 4.500 V + 6 938 8 2.920 V,RNG2 -3.015 mA,M100 2.500 V 4.500 V
I know there are tools for working with fixed width files, but I cannot add anything to the machine that this program will be deployed on (either an old SparcStation or an old HP-UX box). So if it does not come with the workstation's version of Unix, I can't install it. But any other advice would be greatly appreciated.while (<IN>) { chomp; s/,/\t/g; s/\*//g; if ($_ =~ /^[A-Z]/ && $_ !~ /^TT/){ if ($_ !~ /^SERIAL/){$line = "$_"}; }; if (/Part/i) {$pn = substr($_, 32, 32)}; if (/Function/i) {$fn = substr($_, 32, 32)}; if (/Manufacturer/i) {$mn = substr($_, 32, 32)}; if (/Specification/i) {$sp = substr($_, 32, 32)}; if (/Lot/i) {$lt = substr($_, 32, 32)}; if (/AQL/i) {$aq = substr($_, 32, 32)}; if (/Accept/i) {$ac = substr($_, 32, 32)}; if (/Operator ID/i) {$op = substr($_, 32, 32)}; if (/Library/i) {$lb = substr($_, 20, 12)}; if (/Temp/i) {$tm = substr($_, 16, 6)}; if (/SERIAL NUMBER:/i) {$sn = substr($_, 14, 4)}; if (/SERIAL NUMBER:/i) {$ts = substr($_, 32, 64)}; my $col00 = substr $_, 0, 4; my $col01 = substr $_, 4, 4; my $col02 = substr $_, 10, 3; my $col03 = substr $_, 14, 7; my $col04 = substr $_, 22, 2; my $col05 = substr $_, 25, 5; my $col06 = substr $_, 31, 7; my $col07 = substr $_, 38, 2; my $col08 = substr $_, 41, 5; my $col09 = substr $_, 47, 7; my $col10 = substr $_, 55, 3; my $col11 = substr $_, 59, 7; my $col12 = substr $_, 67, 11; print "$col00,$col01,$col02,$col03,$col04,$col05,$col06,$col07,$co +l08,$col09,$col10,$col11,$col12,$line,$pn,$fn,$mn,$sp,$lt,$aq,$ac,$op +,$lb,$tm,$ts,$sn\n" if /^[0-9]/; } close (IN);
In reply to Copy line into new column by softserve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |