spadacciniweb has asked for the wisdom of the Perl Monks concerning the following question:
I have a question. See a code:
Thank you.
at the end, @ip is an array of ip. But, for load @ip I have used a loop while because I useduse strict; use warnings; use Mysql; my @ip; my %record; #### Connect to db my $dbh = Mysql->connect( $mysql_host, $mysql_db, $mysql_user, $mys +ql_pwd); #### Create query my $query = "select ip from mal_switch"; #### query to database my $sth = $dbh->query($query); while (%record = $sth->fetchhash) { push @ip, $record{'ip'}; } print(@ip);
Is there a faster method?%record = $sth->fetchhas
Thank you.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: array from query to db
by rnahi (Curate) on Dec 13, 2005 at 09:08 UTC | |
Re: array from query to db
by Juerd (Abbot) on Dec 13, 2005 at 09:30 UTC | |
Re: array from query to db
by tirwhan (Abbot) on Dec 13, 2005 at 09:00 UTC | |
Re: array from query to db
by holli (Abbot) on Dec 13, 2005 at 08:49 UTC |
Back to
Seekers of Perl Wisdom