Hi Chris,
  Please check added code to yours, in addition to what John wrote;

I am trying to split the first element of an array by white space then
continue reading the rest of the file.
Thus far I am having trouble figuring out how to split the first line.

I would like the first line to be split so it looks like the following
with the "=" sign added.

Thank you in advance!

Chris

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

I am getting the error:

Use of implicit split to @_ is deprecated at ./xxxxx.pl line 6.

#!/usr/bin/perl
use warnings;
use strict;

#while (my @line = <DATA>) {
while (my $line = <DATA>) {
      chomp $line;
  # my $header = split " ",$line[0];
     if($. == 1){   #$. => Current line number for the last filehandle
accessed
       print $_,"=\n" for split/\s+/=>$line;
     }
    else{print $line,"\n";}
  #print $header;
}

__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
1       2       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5
1       3       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5
2       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
2       3       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5
3       1       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5
3       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
4       2       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5
4       3       5.5     5.5     5.5     5.5     5.5     5.5     5.5
 5.5     5.5

Please check perldoc -f split,
also check perldoc perlvar,  for $. => Current line number for the last
filehandle accessed

Regards,
Tim

Reply via email to