SPUG: flip-flops
Colin Meyer
cmeyer at helvella.org
Wed Feb 6 18:27:54 CST 2002
Hi Jason,
On Wed, Feb 06, 2002 at 01:40:29PM -0800, dancerboy wrote:
[...]
>
> Whereas with an operator, I can't do anything like:
>
> $foo = $bar .. $baz;
> print(
> "The current flip-flop state is "
> . ..->get_state()
> . "\n"
> );
>
> Even if ..->method() were legal, it wouldn't do what I want, because
> it's testing the wrong operator. I'd need some way to refer to the
> operator in the previous line, but because it's an operator, there's
> no way to do that.
You can test the state of scalar .. . That's what you typically do
with it.
if ($bar .. $baz) {
print "flip-flop's state is true.\n";
print "Next evaluation will check the right hand term.\n";
}
else {
print "flip-flop's state is false.\n";
print "Next evaluation will check the left hand term.\n";
}
Or you could save that state into a variable, as you did in your
example. You could have said:
print 'The current flip-flop state is: ", $foo?'true':'false', "\n";
You'd rather that there was a FlipFlop class object that provided an
accessor to that state?
Have fun,
-C.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list