Hi, 

I have a weird problem in perl. 

I want to read each line from a file, chomp off the newline character,
append 6694 spaces to the end of each line and then output the line into
a new file.

The code I have is this:

 

while ($line = <Filehandle1>) {

  chomp $line;

  $lengthofLine = length($line);

  for ($i = 0; $i < 6694; $i++) {

    $line = $line.' ';

  }

  print $lengthofLine." ".$line."\n";

 print outfile1 "$lengthofLine"."$line"."\n";

} #endwhile

 

However, the output file looks very strange. The first line doesn't have
any appended spaces whatsoever and from the second line onwards, the
spaces are appended at the beginning of the line instead of the end. 

Please help!!!

 

 

Reply via email to