SPUG: How to use database variable in place of other variable

El JoPe Magnifico jope-spug at jope.net
Fri Mar 15 02:18:25 CST 2002


On Thu, 14 Mar 2002, dancerboy wrote:
> But again, I do agree that this is bad style.  If your intent is to
> make sure that undef values get turned into empty strings, then you
> should do so more explicitly, e.g.:
>
>      my $email = $row[12];
>      $email = '' unless defined $email;
>
> or perhaps:
>
>      my $email = ( defined($row[12]) ? $row[12] : '' );

Heh, I can't wait til Perl 6, when we finally get a defined()-based
version of the current "truth"-based short-circuiting operator "||":

	my $email = $row[12] \\ '';

Yeehaw!  "Use of uninitialized value" warnings... begone!  =)
  -jp


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org





More information about the spug-list mailing list