in reply to Re: faulty expression prob
in thread faulty expression prob
Logically substituting "X" for the conditional expression in parens, "( $rh=$pkg->{'RPM_HDR'} and $dist=$rh->tag('DISTRIBUTION') )", I get (1):return ( $rh=$pkg->{'RPM_HDR'} and $dist=$rh->tag('DISTRIBUTION') ) ? $pkg->{'DIST'}=$dist : $pkg->{'DIST'}=$undef;
AHAH!....I see the prob...that "=" on the "end" (before $undef)... It is lower precedence than the ?: (as mentioned above...but wasn't sure which '=' the '?:' was interfering with). So the above (using D for "$pkg->{'DIST'}) is really (2?):return X ? $pkg->{'DIST'}=$dist : $pkg->{'DIST'}=$undef;
Um...Why wouldn't that be a syntax error? the "(X?D=$dist:D)" part isn't a valid address that can be assigned to. (Note. "$undef" != undef, it's equal to a string of length 5 characters, 'undef'). I can see why what I wrote would be wrong -- but why wouldn't Perl flag it as illegal syntax?return (X ? D=$dist : D ) = $undef;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: faulty expression prob
by jwkrahn (Abbot) on Apr 04, 2008 at 02:41 UTC |