Your first problem would have been made clear if you included use strict; -- it's this line:
$data=~s/2000/2009/g;
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.

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.)


In reply to Re^3: Can't Use String as an Array Ref Help! by graff
in thread Can't Use String as an Array Ref Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.