R
removeps groups
Using Strawberry Perl "This is perl 5, version 16, subversion 1 (v5.16.1) built for MSWin32-x86-multi-thread", the following program compiles and prints out the things noted below.
use strict;
use warnings;
my $myarray = [[1,11], [2,22]];
push(@$myarray[1], 222);
print "MYDEBUG $$myarray[1][0]\n"; # prints 2
print "MYDEBUG $$myarray[1][1]\n"; # prints 22
print "MYDEBUG $$myarray[1][2]\n"; # prints 222
print "MYDEBUG @{$$myarray[1]}\n"; # prints 2 22 222
But on Linux perl "This is perl, v5.6.1 built for i686-linux", the above program results in a compile error
Type of arg 1 to push must be array (not array slice) at array.pl line 4, near "222)"
To get the above program to work in Linux perl, through trial and error, I found this is the script that works:
use strict;
use warnings;
my @tmpmyarray = ([1,11], [2,22]);
my $myarray = \@tmpmyarray;
push(@{$$myarray[1]}, 222);
print "MYDEBUG $$myarray[1][0]\n"; # prints 2
print "MYDEBUG $$myarray[1][1]\n"; # prints 22
print "MYDEBUG $$myarray[1][2]\n"; # prints 222
print "MYDEBUG @{$$myarray[1]}\n"; # prints 2 22 222
This script also works on Strawberry Perl.
Questions:
(1) Is Strawberry Perl wrong to run the first snippet, or is Linux Perl wrong to not run it?
(2) I don't understand the use of $, @, {}, \ to get things working. Is there some logic to it?
use strict;
use warnings;
my $myarray = [[1,11], [2,22]];
push(@$myarray[1], 222);
print "MYDEBUG $$myarray[1][0]\n"; # prints 2
print "MYDEBUG $$myarray[1][1]\n"; # prints 22
print "MYDEBUG $$myarray[1][2]\n"; # prints 222
print "MYDEBUG @{$$myarray[1]}\n"; # prints 2 22 222
But on Linux perl "This is perl, v5.6.1 built for i686-linux", the above program results in a compile error
Type of arg 1 to push must be array (not array slice) at array.pl line 4, near "222)"
To get the above program to work in Linux perl, through trial and error, I found this is the script that works:
use strict;
use warnings;
my @tmpmyarray = ([1,11], [2,22]);
my $myarray = \@tmpmyarray;
push(@{$$myarray[1]}, 222);
print "MYDEBUG $$myarray[1][0]\n"; # prints 2
print "MYDEBUG $$myarray[1][1]\n"; # prints 22
print "MYDEBUG $$myarray[1][2]\n"; # prints 222
print "MYDEBUG @{$$myarray[1]}\n"; # prints 2 22 222
This script also works on Strawberry Perl.
Questions:
(1) Is Strawberry Perl wrong to run the first snippet, or is Linux Perl wrong to not run it?
(2) I don't understand the use of $, @, {}, \ to get things working. Is there some logic to it?