Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Uninitialized value error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-01-07, 14:13
ssmith001 ssmith001 is offline
Registered User
 
Join Date: Sep 2005
Posts: 219
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"); }
Reply With Quote
  #2 (permalink)  
Old 05-01-07, 15:45
KevinADC KevinADC is offline
Registered User
 
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?
Reply With Quote
  #3 (permalink)  
Old 05-01-07, 15:52
ssmith001 ssmith001 is offline
Registered User
 
Join Date: Sep 2005
Posts: 219
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.
Reply With Quote
  #4 (permalink)  
Old 05-01-07, 16:09
KevinADC KevinADC is offline
Registered User
 
Join Date: Feb 2006
Posts: 56
try:

local $" = '';

thats two single-quotes after the equal sign.
Reply With Quote
  #5 (permalink)  
Old 05-01-07, 16:14
ssmith001 ssmith001 is offline
Registered User
 
Join Date: Sep 2005
Posts: 219
Bingo! You are a genius. Thanks!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On