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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.