Hi Dermot,


Dermot wrote:
2008/12/5 Dermot <[EMAIL PROTECTED]>:
+-----------+-----------+--------+------------------------+
| title1 | title2 | oldtitle
------+----------------------------------------------------+
| NULL   | NULL   | The cat jumped over the mat


I used this statement to try and grab 1st, title1; 2nd title2; if all
fails there should be data in oldtitle


my $title = $image->title1 ? $image->title2 : $image->oldtitle;

But that didn't work I got an undef. So I tested with this:



Sorry. Someone on the list mentioned to me before, a reference is
always true, so the test won't work.


Maybe I have missed something, but it sounds like you want something like [NB: This is not Perl code, but sort of pseudocode]:

if (defined (title1)) {
 $title = title1;
}
elsif (defined (title2)) {
 $title = title2;
}
else {
 $title = oldtitle;
}

Is this correct? If so, the ? operator is not what you want. What the operator does is this. For "a ? b : c" it does the test on "a" but not on "b". All it does is say, "Is 'a' true? If so, return 'b'. Otherwise, return 'c'." You aren't doing any test on b, but it sounds like you want to? (Sorry, you showed your table, but you didn't quite explain what title1, title2, and oldtitle means -- so, I am guessing here that you also want to test title2? I am also assuming that you do not want either title1 or title2, but would prefer title1 -- hence the order of the pseudocode above.)

See http://perldoc.perl.org/perlop.html#Conditional-Operator to confirm whether or not it is what you want.

Ray



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


Reply via email to