Try this
%hashVal;
open(FH,"sample.txt")|| die "Could not open $!\n";
@FileLines = <FH>;
$i=0;
foreach $line (@FileLines) {
  my @commaLines = split(/,/,$line);
  $arrval [EMAIL PROTECTED];
  $hashVal{$i} =$arrval;
  $i++;
}

foreach $keyval (keys %hashVal) {
  $ra_val = $hashVal{$keyval};
  foreach $value (@$ra_val) {
    print "$value\n";
  }
}

[EMAIL PROTECTED] wrote:

Greetings,

As a learning Perl Person, this is fun. Would someone please point me in the correct direction to read a comma delimited file and put it into an array? The fields are always in the same position, blank fields will have a comma.
My sample is:


header10,header11,,header13
header20,header21,header22,header23
header30,,header32,header33


I then need to format this data and an array looks like the easiest way of doing this.


Many thanks,

Richard Hug





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to