in reply to Re^2: array to string
in thread array to string

What you've got there is an array reference with one element, which is another array reference with a single element. Change your code to this:

for my $total_info(@$Count) { print "$total_info->[0]\n"; }

In the for statement, you extract a single element of the array in a loop (the inner array reference). The print statement prints out the first element of the inner array reference.

Will you ever get more than one record returned per call? If not, you might consider not using fetchall_arrayref, as that's why you have an aref inside of a top-level aref. fetchall_* implies that you're expecting several records returned. If you only ever expect one piece of data returned per call, use fetchrow_arrayref.

Replies are listed 'Best First'.
Re^4: array to string
by davido (Cardinal) on Oct 13, 2020 at 19:47 UTC

    The output of SELECT COUNT(*)... should always be a single number, so the outer foreach is probably unnecessary:

    print "$Count->[0]->[0]\n";

    Dave

Re^4: array to string
by jcb (Parson) on Oct 14, 2020 at 01:21 UTC

    For SELECT COUNT(*) FROM ... and similar queries that can only return a single value in a single row, the selectrow_array method can directly return the desired information, instead of wrapping it into an arrayref. The DBI documentation has more details, including using that method with previously prepared statements.

Re^4: array to string
by bigup401 (Pilgrim) on Oct 13, 2020 at 18:35 UTC

    thanks guys