[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: if clause



On 08/01/2006 06:07 AM, Dr. Claus-Peter Becke wrote:
Mumia W. schrieb:
On 07/31/2006 11:29 AM, Dr. Claus-Peter Becke wrote:
Mumia W. schrieb:
On 07/31/2006 07:20 AM, Dr. Claus-Peter Becke wrote:
dear mumia w,

thank for your support. as you supposed the values aren't equal. the subroutine's argument is "1". had databaserequest_noun been interpreted in scalar context inside the if-clause, with the result that its value is an integer and not a string as required? is this the reason why the comparison doesn't succeed? and how can i make sure that databaserequest_noun will be interpreted as an array-variable?

best regards
claus-peter becke


if ((function_name($var1,$var2))[0] eq 'MyString') {
}

HTH



dear mumia w,

i have tested the proposal you've made the following way:

if ((databaserequest_noun($col, $table, $case) )[0] eq $Q::lexicalentry) {
  print $q->p("the entry is part of the database");
}else { print    $q->p("the entry isn't part of the database");}

unfortunately it doesn't work. i don't understand the meaning of [0]. could you please explain what's about this expression?

best regards
claus-peter becke


[ Redirected to the list/posted and mailed ]

Again, find out what databaserequest_noun() returns by assigning to a new variable first then printing or by using Data::Dumper:

print Dumper(\databaserequest_noun($col, $table, $case));


The (function())[0] syntax puts the function call into list context so that you can get the first array element ([0]) rather than the array size.



print Dumper(\databaserequest_noun($col, $table, $case))
> returns $VAR1 = \1;


Let's keep it on the list.

Evidently, databaserequest_noun($col, $table, $case) does not return 'Italy.' It returns '1', even in list context.

I have no idea what databaserequest_noun() does. I can't find any information about it on Google. My best advice at this point is to read the documentation (if any) for the function, so you can be sure what the order of the arguments are (the arguments are $col, $table and $case) and what the return value is (in this case, '1').

Good luck.





Reply to: