Re: negate, !!$a, $a!!, flip-flop

2013-09-12 Thread John W. Krahn
Hans Ginzel wrote: Hello! Hello, Is there a shorter way to write $a = ! $a, please? Something analogous to ++ and -- operators like $a !! or !! $a would negate the variable $a and return its previous or new value respectively. You can do that if you use a reference to a scalar like this:

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread David Christensen
On 09/10/13 20:01, John W. Krahn wrote: xor-equals IS assignment and has the same precedence as assignment: Thanks! David -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread John W. Krahn
David Christensen wrote: September 10, 2013 06:15 Hans Ginzel wrote: > Is there a shorter way to write $a = ! $a, please? > Something analogous to ++ and -- operators like $a !! or !! $a would > negate the variable $a and return its previous or new value > respectively. I don't believe Perl

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Casey West
On Mon, Sep 9, 2013 at 5:00 AM, Hans Ginzel wrote: > Hello! > > Is there a shorter way to write $a = ! $a, please? > > Something analogous to ++ and -- operators like $a !! or !! $a would negate > the variable $a and return its previous or new value respectively. > It sounds like what you're req

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Brian Fraser
On Mon, Sep 9, 2013 at 6:00 AM, Hans Ginzel wrote: > Hello! > > Is there a shorter way to write $a = ! $a, please? > > Something analogous to ++ and -- operators like $a !! or !! $a would negate > the variable $a and return its previous or new value respectively. > > Best regards Not really. Bu

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread David Christensen
beginners: Here's a second try at using bitwise xor-equals to implement boolean pre- and post-invert operations for variables containing canonical boolean values (undef, empty string, zero, and one). The pre-invert semantics case (invert, then use) uses the bitwise xor-equals operator and o

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Shawn H Corey
On Tue, 10 Sep 2013 17:04:07 -0700 David Christensen wrote: > scalar ($v ^= 1, !$v) ( ! ( $v ^= 1 )) or do { $v = ! $v; !$v } TIM TOW TDI ;) -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-m

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread David Christensen
September 10, 2013 06:15 Hans Ginzel wrote: > Is there a shorter way to write $a = ! $a, please? > Something analogous to ++ and -- operators like $a !! or !! $a would > negate the variable $a and return its previous or new value > respectively. I don't believe Perl has boolean pre-invert or post

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread David Christensen
On 09/10/13 14:59, David Christensen wrote: Assuming canonical boolean values, post-invert semantics (save the new value into another variable) ... Pre-invert semantics (save the old value into another variable) ... Oops -- it looks like I got my pre- and post- backwards... And, dropping the

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Paul Johnson
On Tue, Sep 10, 2013 at 08:29:00AM -0400, Shawn H Corey wrote: > On Mon, 09 Sep 2013 11:00:31 +0200 > Hans Ginzel wrote: > > > Is there a shorter way to write $a = ! $a, please? > > Why? Because it's the sort of thing one might expect Perl to provide. I know that I have thought that before. ^

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Shawn H Corey
On Mon, 09 Sep 2013 11:00:31 +0200 Hans Ginzel wrote: > Is there a shorter way to write $a = ! $a, please? Why? -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.per

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Dr.Ruud
On 09/09/2013 11:00, Hans Ginzel wrote: Is there a shorter way to write $a = ! $a, please? perl -le ' my @a = (undef, @ARGV); for $a (@a) { my @r; push @r, "$a:"; for (1..3) { push @r, $a^=1; # <-- } print "@r"; } ' 0 1 2 3 -1 : 1 0 1 0: 1 0 1 1: 0 1 0 2: 3 2 3 3:

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread John W. Krahn
Hans Ginzel wrote: Hello! Hello, Is there a shorter way to write $a = ! $a, please? No. John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To

negate, !!$a, $a!!, flip-flop

2013-09-09 Thread Hans Ginzel
Hello! Is there a shorter way to write $a = ! $a, please? Something analogous to ++ and -- operators like $a !! or !! $a would negate the variable $a and return its previous or new value respectively. Best regards HG -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional c