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;.
In reply to Re^2: Adding 2 + 2 (digit-less 1)
by ikegami
in thread Adding 2 + 2
by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |