
Ternary Conditional Operator Question
Quote:
>> > Could someone out there please let me know why this doesn't work:
[ snip code that *does* work ]
Quote:
>> What are you trying to achieve?
>Sorry for being so vague, but I expected it not to work for you the
^^^^^^^^^^
Just write it in the form of a short and complete program, then
run the program, _then_ post that code.
Then we will be troubleshooting the same code that you have,
instead of wasting time on code that does not even really exist.
Quote:
>When I run the above code I get an "unable to modify [something
>something]" with -w (without -w the code just stopped running with no
>complaints).
You should include the exact message text if you want help diagnosing
the problem.
Quote:
>(which happed to be the params passed to my sub. I fixed it by
>it wouldn't work tho'.
Because function args are aliases.
Quote:
>Is that better?
No. It does not execute either.
We cannot see the method call. I'll bet the args in the call
are not lvalues, but I can't really tell because I am troubleshooting
invisible code...
Quote:
>Here's the whole thing:
>package TeamSite::Utils;
>sub slashFix {
> my $self = shift;
^^^^^^
Perl has operators for testing equality. You should use one of
them when you want to test for equality:
^^^^^^^^^^^
The reason would be revealed if we could see the method call.
But we can't. So we cannot help with your real problem...
Quote:
> ($slash =~ m{/}) ? s{\\}{/}g : s{/}{\\}g;
^^^^^^^^^ ^^^^^^^^^
the caller. That would be OK with:
but would complain with:
$util->slashFix( qw/zero one two three/ );
because the are not lvalues in the second case.
--
Tad McClellan SGML consulting
Fort Worth, Texas