[Omaha.pm] Converting an array of strings into a scalar

Ryan Stille rps at willconsult.com
Tue Feb 22 08:59:46 PST 2005


I have an array of lines, each one containing a newline character at the
end.  I want to convert this to a scalar variable that I will pass on to
something else.

I was using
$body = "@filecontents";

But that ends up adding a space to the beginning of each line except the
first one.  So I changed it to this:

$body = '';
foreach $line (@filecontents) {
  $body .= $line;
  }

But I wonder if there is a more elegant way?

-Ryan



More information about the Omaha-pm mailing list