Next | Program Repair Shop | 206 |
Sometimes you see even more bizarre examples:
Subject: Retrieving an Entry Within a File Message-Id: <MPG.139f24a68ea4317f989682@News.CIS.DFN.DE>
if ($device eq $_) {
$mail{To} = 'pager@domain.com'; } else { if ($device ne $_) {$mail{To} = 'email@domain.com'; }
The previous slide says this should be:
if ($device eq $_) { $mail{To} = 'pager@domain.com'; } elsif ($device ne $_) { $mail{To} = 'email@domain.com'; }
But really it should be:
if ($device eq $_) { $mail{To} = 'pager@domain.com'; } else { $mail{To} = 'email@domain.com'; }
Exercise: Would it be better to write
$mail{To} = ($device eq $_) ? 'pager@domain.com' : 'email@domain.com';
$mail{To} = ($device eq $_ ? 'pager' : 'email') . '@domain.com';
Next | Copyright © 2002 M. J. Dominus |