Gossamer Forum
Home : General : Perl Programming :

dubbel check

Quote Reply
dubbel check
Hi,

The sub below does:

IF field empty print > regular
ELSIF hyperlink field > print hyperlink
ELSE print > regular

But better should be:

IF hyperlink field AND NOT nothing print > hyperlink
ELSE: print regular

The question is only how?

Code:
if ($rec{$field} =~ /^\s*$/) { # entry is null or only whitespace
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font>$rec{$field} </font></td></tr>
~;
} elsif ($db_hyperlink_fields{$field}) {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font><a href="$db_hyperlink_fields{$field}$rec{$field}" target="_new">$rec{$field}</a> </font></td></tr>
~;
} else {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font>$rec{$field} </font></td></tr>
~;
}

Quote Reply
Re: dubbel check In reply to
I think I found it myself :-)

The following seems to work:
Code:
if (($db_hyperlink_fields{$field}) && ($rec{$field} !~ /^\s*$/)) {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font><a href="$db_hyperlink_fields{$field}$rec{$field}" target="_new">$rec{$field}</a> </font></td></tr>
~;
} else {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font>$rec{$field} </font></td></tr>
~;
}