in reply to Re^2: Can't Use String as an Array Ref Help!
in thread Can't Use String as an Array Ref Help!
That's the first mention of a variable named "$data" -- previously, you assigned a value from the DB to a variable called "$date". Apart from that, I can't see how $date =~ s/2000/2009/g would have any effect, unless your database server is seriously broken: your query specifically asks for rows where the date contains "2009", not "2000", so that s/// statement is a no-op.$data=~s/2000/2009/g;
A couple lines later, there's a "$user7" variable being assigned to your $new_array_ref, but that was never mentioned previously either.
Also, after making the connection for "$dbh_b", your "map" block uses something called "$dbh_sec" as if it were some kind of object, but that's the only mention of $dbh_sec. Bottom line: the code you posted will not run.
As for pushing rows of field data into an AoA ref, I'll just repeat what was already mentioned in an earlier reply -- you do it like this (note the use of square brackets):
my $new_array_ref; foreach my $vals (@$array_ref) # I'd use "$row" instead of "$vals", +but whatever { my ($acc_num,$date,$user1,$user2,$email,$user4,$user5,$user6,$coun +try) = @$vals; # do some edits that make sense... and then: push @$new_array_ref, [$date, $user1, $user2, ... ]; }
There's no need (no use) for me to go any further. You actually didn't follow my earlier suggestion, and until you do start to follow suggestions, there's not much point trying to help you. So to repeat:
USE STRICT. The things you need to do in order to make the script compile with use strict will probably fix your problems.
Come up with a version of the code that includes "use strict" and actually compiles, runs and produces some specific result (whether an error message or some sort of data output).
If the result is the intended data, you're done (yay!). If not, and if you really can't figure out the problem on your own, show us the specific result that is relevant to the problem (exact error message, Data::Dumper output or whatever -- but keep it brief and relevant).
If there's an error with a line number show us the specific line of code in question, with just the relevant background code to show how the variables in the error line were set up. (Posting a long stream of code that does not compile will not help you here, and will only annoy people.)
|
|---|