On Jun 18, 8:48 am, [EMAIL PROTECTED] (Jefferson Kirkland) wrote:

>     my $emailBody = $prefix . "emailbody";

> The problem is when I get down to the part after the emailbody files are
> populated ( they are only populated if files exist) that checks to see if
> the files are of zero size.  If they are of zero size, it is supposed to put
> a message into the log file saying there are no files for that directory.
> If they have size (which means they have a message for the distribution
> list, it is supposed to trigger the email program to notify the users.  Here
> is the code that wasn't working:
>
>     if(-z $emailBody)
>     {
>         print LOGFILE ("No files found in $dir \n");
>     }
>     else
>     {
>         print LOGFILE ("Files found in $dir.  Sending email to distribution
> list. \n");
>
>         $subject = "Files To Retrieve In Directory: $dir \n";
>         $recipients = $prefix . "Emails.txt";
>
>         `email program trigger`;
>     }
>
> I know that I said "wasn't" in my last statement.  One of my colleagues
> discovered that if he puts a "chomp($emailBody);" right before this
> statement that it seems to work just fine instead of failing.   Now, as I
> mentioned the code before this that checks if the file exists, using THE
> SAME variable works fine.  Why would I now, at this point, only a dozen
> lines later, have to "chomp" the variable to get this to work?  It isn't
> like the value was supplied from the command line, it is set in the script.
> Granted, it is inside of a foreach loop that is cycling through the
> different directories and setting the variable per the directory, but it is
> all done in the script.
>
> Does anyone have any idea why this would have to be chomped at this stage of
> the script?

There's no reason, from what you've told us.  chomp() would have no
effect on that variable, as it doesn't end in a newline.  My guess is
that either you're leaving out an important detail for the sake of
brevity, or your coworker changed something else too, but mistakenly
believed it was the chomp() that solved the problem.

Can you create a short-but-complete script that demonstrates the
original failure, and then a version that has only the additional
chomp() line inserted but suddenly works correctly?

Also, what is meant by "it doesn't work" in your question?  What did
not work?  How did it not work?  What errors did you receive?

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to