Friday, December 07, 2001, 5:18:38 AM, Aaron Shurts wrote:
AS> Okay, I was the one that asked the crazy question about the weird join,
AS> but I got that figured out.  Now I have a problem.

AS> while( ($login, $existingemail, $areacode, $prefix, $rest) =
$sth->>fetchrow_array ())
AS>     {
AS>         print "$login,$existingemail,$areacode-$prefix-$rest\n";
AS>     }

AS> That code is inside my foreach statement, but existingemail is an
AS> optional field.  If there is no email address given, I would like to
AS> print out "NO EMAIL PROVIDED".  How do I do this within my while loop.
AS> When this report is run, it is piped to a csv file so that it can easily
AS> be imported into Excel.  Thanks in advance for the help.

you could do

  while(( $a, $b, $c) = ...) {
    $b ||= "NO EMAIL";
    ...
  }

which says "if $b is false, then assign it 'NO EMAIL'". this is a nice
generic little way for setting up default values.

the only issue with it is if $b already contains a false value that
you want to keep (eg 0) it will be overwritten, although with email
addresses that's not a problem. perl 6 is going to have //= which does
the same thing as ||= but only assigns if $b is undef.


-- 
Best regards, Daniel

Bershere's Formula for Failure: There are only two kinds of people who fail:
those who listen to nobody... and those who listen to everybody.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to