I'm getting a bit closer. There a couple roadblocks I am up against.

I am able to split the lines by white space, but for some reason the
program isn't capturing the first lines to the @fieldValue array after
the @headerNames array.
Once I get all the lines to go into the array correctly I would like
to combine the @headerNames and @fieldValue arrays. The way I am doing
it now only appends the later.
I would like the combination to be the below for each elements in the
two arrays.

any help is greatly appreciated,

Chris

csno=1
rfpi=1
header_1=5.5
header_2=5.5
header_3=5.5
header_4=5.5
header_5=5.5
header_6=5.5
header_7=5.5
header_8=5.5
header_9=5.5



#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my $header;
my @headerNames;
my $field;
my @fieldValue;
my @apxScript;

while (my $line = <DATA>) {
  if($line =~ m|(.*_.*\n)|){
  $header = $1;
  @headerNames = split(" ",$header);
  }

  if($line !~ m|.*_.*\n|){
  @fieldValue = split(" ",$line);
  print "$fieldValue[0]\n";
  }
}

my @apxScript=(@headerNames, @fieldValue);
print Dumper \@headerNames;
print Dumper \@fieldValue;
print Dumper \@apxScript;


__DATA__
csno  rfpi  header_1  header_2  header_3  header_4  header_5  header_6
 header_7  header_8  header_9
1 1 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
2 2 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
3 3 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
4 1 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
5 2 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
6 3 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
7 1 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
8 2 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
9 3 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
10  1 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
11  2 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
12  3 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to