Hi there Monks!
I need to edit some of the data coming back from my query here before printing the results.
I am doing something wrong here, is this the proper way to create a new array ref with the edited values?
How could I do this?
...
my $sth = $dbh->prepare($sql)|| die $dbh->errstr;
$sth->execute() or die "$!\n";
my $ary_ref = $sth->fetchall_arrayref();
my $new_array_ref;
foreach my $val (@$ary_ref){
my ($one, $two, $three, $four, $five, $six, $seven, $eight, $nine, $te
+n, $eleven) =@$val;
#edit here
$one=~s/2009/01112009/g;
$five=~s/204/APROV/g;
$six=~s/john/John/g;
#Data edited ready for the array ref
push @{$new_array_ref} ,$one, $two, $three, $four, $five, $six, $seven
+, $eight, $nine, $ten, $eleven;
}
print Dumper ($new_array_ref);
I am getting an error like : "Can't use string (" SOMETHING ") as an array ref while " strict refs" in use"
Thanks a lot!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.