Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrays with 2 ENDs

Status
Not open for further replies.

keid

Technical User
Aug 8, 2006
22
DE
Hello

I have to store 2 arrays out of the lines starting with part after the line of the CNTC 205

Code:
CNTC 205
        PART               1        2
        END
        PART               4
        END

in other words i need to make a set of parts
@first_part of CNTC 205= 1 2
@second_part of CNTC 205= 4

I used a code like that
Code:
sub part_entity_sel($)
{
  my $line  = shift;
  my @rb;
  push @rb, $line;

  # get data
  my $read_more = 1; 
  while ($read_more) {
      $line = <DAT_PC>;
      push @rb, $line;
      $read_more = 0 if $line =~ m/^\s{8}END/;
  }

  # get parts
  my @nlist;
  foreach $line (@rb){
      if ($line =~ m/^\s{8}PART/) {
          (my $line2 = $line) =~ s/^\s*PART\s*//;
          push @nlist, split(/\s+/, $line2);
      }
  }
return @nlist;
}

this works only with one END, any ideas how to modify this to work with 2 ENDS?

thanks alot in advance
 
Create an array of arrays.

$line =~ /^\s+PART\s+//;
push(@{$hash_array{$CNTC_CODE}[$Part_index]}, (split(/\s+/, $line)));


Michael Libeson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top