Results 1 to 3 of 3
Please help me understanding the meaning of following in Perl Script
my $type;
my sth =$db->prepare($sql);
my $sth->execute();
while (my $var = $sth->fetchrow_arrayref){
$type->{"@$var[0]"}=" ";
}...
- 01-28-2008 #1Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Query in PerlCGI & DBI ------ @$var[0] ???
Please help me understanding the meaning of following in Perl Script
my $type;
my sth =$db->prepare($sql);
my $sth->execute();
while (my $var = $sth->fetchrow_arrayref){
$type->{"@$var[0]"}=" ";
}
- 01-28-2008 #2
Does this code actually work?
The reason I ask is this: $var is currently an arrayref. However, it seems like two techniques were combined here. They are dereferencing the arrayref into an array ("@$var"), but they are then taking an array index. If you wanted to take the index of an arrayref, you would usually do "$var->[0]".
Combine that with the fact that it's wrapped in a string, and this code becomes _very_ strange.
What are you trying to accomplish with this?DISTRO=Arch
Registered Linux User #388732
- 01-28-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Even I am not able run the same but I don't how its working for long time.
Following is another same kind code, have a look. If you can help me to understand.
$sq = "select distinct date from sr_stats";
$sth = $db->prepare($sq) or die "Cannot prepare: " . $db-errstr();
$sth->execute() or die "Cannot execute: " . $sth->errstr();
while (my $var = $sth->fetchrow_arrayref) {
$dates->{"@$var[0]"}=" ";
}


Reply With Quote