http://www.perlmonks.org?node_id=597169


in reply to Re: Adding 2 + 2
in thread Adding 2 + 2

That's really an interesting way of getting 1, not 2. Other interesting ways to get 1:

my $one = !@!; my $one = !!$]; my $one = /.*/; # Side-effect: Changes $1, etc my $one = $$/$$; my $one = ()=$$; my $one = @{[$$]}; my $one = 'a'^'P'; # Character set specific. my $one = ord('b')-ord('a'); # Character set specific.

And 2:

my $two = $one+$one; my $two = $one<<$one; my $two = ()=qw(a a); my $two = @{[ qw(a a) ]}; my $two = ()=/(.*)(.*)/; # Side-effect: Changes $1, etc my $two = 'a'^'S'; # Character set specific. my $two = ord('c')-ord('a'); # Character set specific.

None of these have side effects unless otherwise noted.
All of these run under use strict;.
All of these run silently under use warnings;.