Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: Anyone use "xor" in conditionals?

by Cody Pendant (Prior)
on Jul 14, 2003 at 11:24 UTC ( [id://273945]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Anyone use "xor" in conditionals?
in thread Anyone use "xor" in conditionals?

I'm a bit confused by these flipflops being used, as well as the ternary thing, to alternate colours.

I long ago whittled it down to just

$bgcolor = ($bgcolor eq 'white'?'black':'white');
which flips itself.

“Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
M-J D

Replies are listed 'Best First'.
(jeffa) 4Re: Anyone use "xor" in conditionals?
by jeffa (Bishop) on Jul 14, 2003 at 13:51 UTC
    Check out Tie::Toggle:
    use Tie::Toggle; tie my $toggle, 'Tie::Toggle'; my @color = qw(black white); print "$color[$toggle]\n" for 1..10;
    Using more than one color? Tie::Cycle
    use Tie::Cycle; tie my $color, 'Tie::Cycle', [qw(red white blue)]; print "$color\n" for 1..10;
    Combine that with Color::Spectrum:
    use Tie::Cycle; use Color::Spectrum qw(generate); tie my $color, 'Tie::Cycle', [generate(4,'#ff00ff','#00ff00')]; print "$color\n" for 1..10;

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Or Tie::FlipFlop:
      use Tie::FlipFlop; tie my $flipflop => 'Tie::FlipFlop', qw /black white/; print $flipflop; # black print $flipflop; # white print $flipflop; # black print $flipflop; # white

      Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://273945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-19 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found