Hi I was wondering if you could help with a couple last things. I have modified the code to take input from a file and also I have commented out everything to make sure I understand it. And by the way I have gone with the first method you provided.
My first problem is getting the output to a new file rather than to the terminal. I have tried several different methods of this and have failed.
The second problem is in the data itself. Every once in a while the data may look like this because there are two many of the tags for one id:
10GBE_ADDR1 R3629.2 (ANALOG:107) R3633.1 (ANALOG:107)
U212.19 (INPUT:107)
Basically it will start a new line to write all of the tags. I am not sure how to recognize that there is no id and how to then make the following tags attribute themselves back to the previous id. And here is the code I used.
open FILE, '<', "golden.rpt" or "die unable to open read file $!"; while (my $line = <FILE>) { next if $line =~ /^\s*$/; #skip blank lines next if $line =~ /#/; #Skip comments my ($netname, @referencedesignators) = split ' ', $line; #split file + into a scalar for netname and put all of the reference designators i +nto an array my @singlereference; while (@referencedesignators) { my $firstpart = shift @referencedesignators; #split array into tw +o scalars one for the letter then number sequence and the other for t +he analog thing my $secondpart = shift @referencedesignators; push @singlereference, "$firstpart $secondpart"; #push these two +scalars to form a pair. Each pair is one reference designator. These +pairs form an array. } @singlereference = sort {$a <=> $b} @singlereference; #sort by ascen +ding foreach my $col (@singlereference) { print "$netname $col\n"; #print the netname along with each colum +n of the array containing the singlereference designators. } } print "done\n";
In reply to Re^4: Perl Formatting Text
by oopl1999
in thread Perl Formatting Text
by oopl1999
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |