in reply to Re^3: Print array from here-doc
in thread Print array from here-doc

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"); }

Replies are listed 'Best First'.
Re^5: Print array from here-doc
by akho (Hermit) on Apr 25, 2007 at 21:30 UTC
    How are you calling the subroutine? If you do

    ReportThreshholdExceeded $thing1, $thing2, $thing3;

    then $output_array = $thing1. Maybe you actually meant

    my @output_array = @_; my $text = join "\t", @output_array; ...

    This puts all parameters in $output_array.

      This is how I call it: ReportThreshholdExceeded( @output_array );
        You should either call it like ReportThreshholdExceeded(\@output_array)<\c> (this will put a reference to <c>@output_array in the sub's $output_array or write it like I suggested in the GP post.

        Currently the sub's $output_array only contains the first element of the caller's @output_array.