in reply to Returning two records with SELECT statement and then printing to file

You're storing the return value of fetchrow_array in @regions_A, but then printing $_. Are you sure that fetchrow_array populates $_?

Even if it turns out that $_ does get populated when fetchrow_array returns, you should use @regions_A while printing to make your code more readable.

Replies are listed 'Best First'.
Re^2: Returning two records with SELECT statement and then printing to file
by andreas1234567 (Vicar) on Dec 07, 2007 at 13:52 UTC
    fetchrow_array does not set $_:
    use strict; use warnings; use DBI; my $dbh = DBI->connect("DBI:mysql:test", '*', '*') or die("booh"); my $sth = $dbh->prepare("select value from s") or die ("looh"); $sth->execute() or die("hoo"); while (my @array = $sth->fetchrow_array()) { defined($_) ? print "$_\n" : die "\$_ is undef\n"; } __END__ $_ is undef
    --
    Andreas