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:
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/
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
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
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
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
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
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
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
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.
^
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
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:
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
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
14 matches
Mail list logo