M
msbrentlinger
please help.. im just now getting into references and im so very lost.
the following code
use strict;
use warnings;
my @src_dbs = qw(a b c); # add more dbs to compare to here
my @data_src;
foreach (@src_dbs){
print "getting data from db $_\n";
push @data_src, &get_db_data($_);
}
print "\nthere are ",scalar(@data_src)," arrays\n";
print "\narray one has ",scalar($data_src[0])," items\n"; # <<< __i
think this is my problem, but how should i refer to this array to get
the # of items correctly ?
foreach (@data_src){
print "\ndb $$_[3] data (ref to with $_) has ",scalar(@$_)," items,
which are: @$_";
}
sub get_db_data {
my @a = qw(1 2 3);
push @a, $_;
push @a, '5' if $_ eq 'c'; # test for bad data
return (\@a);
}
returns
getting data from db a
getting data from db b
getting data from db c
there are 3 arrays
array one has ARRAY(0x186932c) items
db a data (ref to with ARRAY(0x186932c)) has 4 items, which are: 1 2 3
a
db b data (ref to with ARRAY(0x18691f4)) has 4 items, which are: 1 2 3
b
db c data (ref to with ARRAY(0x18692cc)) has 5 items, which are: 1 2 3
c 5
when id rather it return
getting data from db a
getting data from db b
getting data from db c
there are 3 arrays
array one has 4 items
db a data (ref to with ARRAY(0x186932c)) has 4 items, which are: 1 2 3
a
db b data (ref to with ARRAY(0x18691f4)) has 4 items, which are: 1 2 3
b
db c data (ref to with ARRAY(0x18692cc)) has 5 items, which are: 1 2 3
c 5
i know im just not referring to my array right to get a number of items
for array one. but everything i try just results in errors. appearantly
i just dont understand. any advice would be greatly appreciated
the following code
use strict;
use warnings;
my @src_dbs = qw(a b c); # add more dbs to compare to here
my @data_src;
foreach (@src_dbs){
print "getting data from db $_\n";
push @data_src, &get_db_data($_);
}
print "\nthere are ",scalar(@data_src)," arrays\n";
print "\narray one has ",scalar($data_src[0])," items\n"; # <<< __i
think this is my problem, but how should i refer to this array to get
the # of items correctly ?
foreach (@data_src){
print "\ndb $$_[3] data (ref to with $_) has ",scalar(@$_)," items,
which are: @$_";
}
sub get_db_data {
my @a = qw(1 2 3);
push @a, $_;
push @a, '5' if $_ eq 'c'; # test for bad data
return (\@a);
}
returns
getting data from db a
getting data from db b
getting data from db c
there are 3 arrays
array one has ARRAY(0x186932c) items
db a data (ref to with ARRAY(0x186932c)) has 4 items, which are: 1 2 3
a
db b data (ref to with ARRAY(0x18691f4)) has 4 items, which are: 1 2 3
b
db c data (ref to with ARRAY(0x18692cc)) has 5 items, which are: 1 2 3
c 5
when id rather it return
getting data from db a
getting data from db b
getting data from db c
there are 3 arrays
array one has 4 items
db a data (ref to with ARRAY(0x186932c)) has 4 items, which are: 1 2 3
a
db b data (ref to with ARRAY(0x18691f4)) has 4 items, which are: 1 2 3
b
db c data (ref to with ARRAY(0x18692cc)) has 5 items, which are: 1 2 3
c 5
i know im just not referring to my array right to get a number of items
for array one. but everything i try just results in errors. appearantly
i just dont understand. any advice would be greatly appreciated