use Perl or die;
#!/usr/bin/perl use strict; my $x = ('a', 'b'); print $x;
b
#!/usr/bin/perl use strict; my @a = ('a', 'b'); my $x = @a; print $x;
2
#!/usr/bin/perl my @a = ('a', 'b'); my ($x) = @a; print $x;
a
#!/usr/bin/perl my @a = ('a', 'b'); print scalar @a;
2
#!/usr/bin/perl print scalar ('a', 'b');
b
#!/usr/bin/perl $\ = "\n"; my $x = ('a', 'b', 'c'); print "x = $x"; my $x = @{['a', 'b', 'c']}; print "x = $x"; my $x = (@{['a', 'b', 'c']}); print "x = $x";
x = c
x = 3
x = 3
#!/usr/bin/perl use strict; my $x; my $y; $y = ($x = ('a', 'b', 'c')); print "x = $x\n"; print "y = $y\n";
x =
y =
#!/usr/bin/perl use strict; my $x; my $y; $y = (($x) = ('a', 'b', 'c')); print "x = $x\n"; print "y = $y\n";
x = a
y = 3
use Perl or die;
#!/usr/bin/perl use strict; use Data::Dumper; sub test1 { my %hash; $hash{shift} = 1; print Dumper \%hash; } sub test2 { my %hash; $hash{+shift} = 1; print Dumper \%hash; } test1('test'); test2('test');
$ VAR1 = { 'shift' => 1 }; $ VAR1 = { 'test' => 1 };
s ggggg;
s///g;
perl -MO=Deparse -le "s ggggg;"
BEGIN {$ / = "\ n"; $ \ = "\ n"; } s /// g; -e syntax OK
#!/usr/bin/perl use strict; use Data::Dumper; use constant key => 1; my %hash; $hash{key} = 1; print Dumper \%hash; my %hash2; $hash2{+key} = 1; print Dumper \%hash2; my %hash3; $hash3{-key} = 1; print Dumper \%hash3;
$ VAR1 = { 'key' => 1 }; $ VAR1 = { '1' => 1 }; $ VAR1 = { '-key' => 1 };
$x = (($foo,$bar) = f());
Source: https://habr.com/ru/post/150140/
All Articles