A
Aaron Anodide
Hi,
I'm fairly new to PERL. The following code fetches a row from DBI as
an array ref. It then sends a reference to an element of that array
to a sub which modifies it in place. This effectively (i think)
modifies the original string which was returned by DBI.
My question is: Is this OK? Are the scalars in the array returned
from DBI special in any way, such that I might corrupt memory by doing
this?
Thanks in advance,
Aaron Anodide
sub CleanXMLString
{
my $s_ref = shift;
$$s_ref =~ s/\&/\&\;/g;
$$s_ref =~ s/\</\<\;/g;
$$s_ref =~ s/\>/\>\;/g;
}
my $sql = "SELECT x,y FROM TT WHERE ID=1";
$sth = $dbh->prepare($sql);
$sth->execute();
$row_ref = $aref = $sth->fetchrow_arrayref;
CleanXMLString( \$row_ref->[0] );
CleanXMLString( \$row_ref->[1] );
I'm fairly new to PERL. The following code fetches a row from DBI as
an array ref. It then sends a reference to an element of that array
to a sub which modifies it in place. This effectively (i think)
modifies the original string which was returned by DBI.
My question is: Is this OK? Are the scalars in the array returned
from DBI special in any way, such that I might corrupt memory by doing
this?
Thanks in advance,
Aaron Anodide
sub CleanXMLString
{
my $s_ref = shift;
$$s_ref =~ s/\&/\&\;/g;
$$s_ref =~ s/\</\<\;/g;
$$s_ref =~ s/\>/\>\;/g;
}
my $sql = "SELECT x,y FROM TT WHERE ID=1";
$sth = $dbh->prepare($sql);
$sth->execute();
$row_ref = $aref = $sth->fetchrow_arrayref;
CleanXMLString( \$row_ref->[0] );
CleanXMLString( \$row_ref->[1] );