in reply to Print array from here-doc

You will probably want to format your array too (it looks like you want to print a table). Why not use formats?

upd Sorry, I failed to notice you actually want to get a string, not print it.

You still should format this array somehow, like add necessary spaces or somesuch.

my $text = join "\t", @{$array}; my $msg = <<"END"; stuff $text END

may help.

Replies are listed 'Best First'.
Re^2: Print array from here-doc
by sasrs99 (Acolyte) on Apr 25, 2007 at 21:10 UTC
    Yes, all I want to do is to print the array elements in the message body. Can I do that using formats?
      I've somehow fixed my original reply.
        I think I'm closer, but it only prints the 1st array element
        sub ReportThreshholdExceeded { my $output_array = shift; my $text = join "\t", @{$output_array}; LogMsg("Running ReportThreshholdExceeded"); my $msg = <<END_OF_BODY; The number of SKUs that have been flagged as DeleteMe is greater than +the threshold of $threshold and thus Manager approval is required. Here is the list of SKUs and their counts: PLANNERCODE\tDEALER\tCOUNT ================================= $text The MDI Server END_OF_BODY my $address = "ssmith\@xyz.com"; open(MAILER, "| mailx -s \"Manager Approval Required for DeleteMe +flagged SKUs on $instance\" $address") or warn("Couldn't start mailx: $!\n"); print MAILER $msg; # send the mail close(MAILER); LogMsg("Email sent"); }