Ing. Branislav Gerzo <[EMAIL PROTECTED]> wrote: : Charles K. Clarkson [CKC], on Monday, November 15, 2004 at : 09:20 (-0600) typed: : : : : $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; } : : $seen{$item} = $seen{$item} ? ++$seen{$item} : 1; : : ok I understand, but I don't know why my line doesn't work. I : thought (exp) ? (true) : (false) is the same as if (exp) { } : else { }
Further investigation leads me to believe perl interpreted your original statement: $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; As this: ( $seen{$item} ? $seen{$item}++ : $seen{$item} ) = 1; When you probably meant this: $seen{$item} ? ($seen{$item}++) : ($seen{$item} = 1); According to the docs: "The operator may be assigned to if both the 2nd and 3rd arguments are legal lvalues." A post increment is not a valid lvalue. You are basically saying this. if ( $seen{$item} ) { $seen{$item}++ = 1; } else { $seen{$item} = 1; } HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>