Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2005
    Posts
    220

    Unanswered: Uninitialized value error

    I can't seem to figure out why I am getting the "Use of uninitialized value in join or string" error from this sub. Can anyone give me a clue? I have already used Dumper to validate the fact that @output_array does not contain any undef.

    Code:
    sub ReportThreshholdExceeded
    {
    	  my @output_array = @_;
    		
    		LogMsg("Running [ReportThreshholdExceeded]");
    				
    		local $"; 
    				
        my $msg = <<END_OF_BODY;
    
    The number of SKUs/DFUs that have been flagged as DeleteMe is greater than the threshold of $threshold so Manager approval is required.
    
    Here is the list of SKUs/DFUs and their counts:
    
    TYPE\tPLANNERCODE\tDEALER\tCOUNT
    =======================================
    @{ [ map { sprintf qq{%3s\t%10s\t%15s\t%18d\n}, @$_ } @output_array ] }
    
    
    END_OF_BODY
    
        my $address = "john.doe@xyz.com ";       
    
        open(MAILER, "| mailx -s \"IMPORTANT: Manager Approval Required for DeleteMe flagged SKUs/DFUs on $instance\" $address")
                   or warn("Couldn't start mailx: $!\n");
    
        print MAILER $msg;       # send the mail
    
        close(MAILER);
        
        LogMsg("Email sent to: $address");
    }

  2. #2
    Join Date
    Feb 2006
    Posts
    56
    this line might be the problem:

    my $address = "john.doe@xyz.com ";

    @xyz is being interpolated as an array because of the double-quotes. So $address is defined as john.doe.com (assuming there is no array @xyz). Change the double-quotes to single-quotes:

    my $address = 'john.doe@xyz.com ';

    note there is also a space on the end of that string after .com, don't know if you want it there or not. Also, $threshold and $instance are only used once in that block, are they global variables?

  3. #3
    Join Date
    Sep 2005
    Posts
    220
    Kevin, sorry to lead you down the wrong path. I had removed my email address and replaced it with john.doe@xyz.com and I had forgotten to add the "\" before the "@", and yes, $instance and $threshold are global.

    When I comment out the local $"; line it works without the error, but all the records of the output_array that go to the email are indented 1 space.
    Last edited by ssmith001; 05-01-07 at 16:03.

  4. #4
    Join Date
    Feb 2006
    Posts
    56
    try:

    local $" = '';

    thats two single-quotes after the equal sign.

  5. #5
    Join Date
    Sep 2005
    Posts
    220
    Bingo! You are a genius. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •