in reply to DBI fetchrow_hashref issue
Your DBI stuff is fine. Your problem is your reference syntax. Try this:
while($info = $sth->fetchrow_hashref) { for (keys %$info) { print "$_ => $$info{$_}\n"; } }
You can also use %{$info} instead of %$info, but IMO that syntax is noisier and usually unnecessary. (Sometimes you have to use it, for example when you are interpolating and the variable is directly followed by word characters that would otherwise be taken for part of the variable name.)
The syntax you use, %{info}, is exactly the same as saying %info -- that is to say, it doesn't dereference $info, but refers to a completely separate variable instead, a hash variable called %info. You want either %{$info} or %$info.
You may also occasionally see an arrow syntax, like $info->{key} = $value, but for now you don't need to worry about that. Just know that when you do see it, it's a dereferencing syntax.
The reason for the %{info} syntax is so that 'info' can be replaced with an arbitrary expression. For example, under no strict refs you could say %{"in" . "fo"} and it would still refer to %{info}. It does not however refer to the same thing as %{$info}.
|
|---|