F
Franck
Hi!
Little problem there. Can someone tell me what's the problem with
this? The first test below works while the second doesn't. I have to
use strict so I need to know why it doesn't work and what I have to do
to fix the problem in the second test. It complains when I put items
in the second dimension of the array..."Can't use string ("group 0")
as an ARRAY ref while "strict refs" in use at test.pl line 18."
Thx a lot!
Franck
#################################################
#FIRST TEST
$i = 0;
$j = 0;
$k = 0;
@data = ();
for ($i=0; $i<=3; $i++){
$data[$i] = "group $i";
for ($j=0; $j<=3; $j++){
$temp1 = $j+$i+10;
$data[$i][$j] = "user $temp1";
for ($k=0; $k<=3; $k++){
$temp2 = $k+100;
$data[$i][$j][$k] = " $temp2";
}
}
}
for ($i=0; $i<=3; $i++){
print "\n\n$data[$i] own: ";
for ($j=0; $j<=3; $j++){
print "\n $data[$i][$j] who have privilege ";
for ($k=0; $k<=3; $k++){
print "$data[$i][$j][$k],";
}
}
}
#################################################
#################################################
#SECOND TEST
use strict;
use warnings;
my $i = 0;
my $j = 0;
my $k = 0;
@::data = ();
my $temp1;
my $temp2;
for ($i=0; $i<=3; $i++){
$::data[$i] = "group $i";
for ($j=0; $j<=3; $j++){
$temp1 = $j+$i+10;
$::data[$i][$j] = "user $temp1";
for ($k=0; $k<=3; $k++){
$temp2 = $k+100;
$::data[$i][$j][$k] = " $temp2";
}
}
}
for ($i=0; $i<=3; $i++){
print "\n\n$::data[$i] own: ";
for ($j=0; $j<=3; $j++){
print "\n $::data[$i][$j] who have privilege ";
for ($k=0; $k<=3; $k++){
print "$::data[$i][$j][$k],";
}
}
}
#################################################
Little problem there. Can someone tell me what's the problem with
this? The first test below works while the second doesn't. I have to
use strict so I need to know why it doesn't work and what I have to do
to fix the problem in the second test. It complains when I put items
in the second dimension of the array..."Can't use string ("group 0")
as an ARRAY ref while "strict refs" in use at test.pl line 18."
Thx a lot!
Franck
#################################################
#FIRST TEST
$i = 0;
$j = 0;
$k = 0;
@data = ();
for ($i=0; $i<=3; $i++){
$data[$i] = "group $i";
for ($j=0; $j<=3; $j++){
$temp1 = $j+$i+10;
$data[$i][$j] = "user $temp1";
for ($k=0; $k<=3; $k++){
$temp2 = $k+100;
$data[$i][$j][$k] = " $temp2";
}
}
}
for ($i=0; $i<=3; $i++){
print "\n\n$data[$i] own: ";
for ($j=0; $j<=3; $j++){
print "\n $data[$i][$j] who have privilege ";
for ($k=0; $k<=3; $k++){
print "$data[$i][$j][$k],";
}
}
}
#################################################
#################################################
#SECOND TEST
use strict;
use warnings;
my $i = 0;
my $j = 0;
my $k = 0;
@::data = ();
my $temp1;
my $temp2;
for ($i=0; $i<=3; $i++){
$::data[$i] = "group $i";
for ($j=0; $j<=3; $j++){
$temp1 = $j+$i+10;
$::data[$i][$j] = "user $temp1";
for ($k=0; $k<=3; $k++){
$temp2 = $k+100;
$::data[$i][$j][$k] = " $temp2";
}
}
}
for ($i=0; $i<=3; $i++){
print "\n\n$::data[$i] own: ";
for ($j=0; $j<=3; $j++){
print "\n $::data[$i][$j] who have privilege ";
for ($k=0; $k<=3; $k++){
print "$::data[$i][$j][$k],";
}
}
}
#################################################