Reputation: 1
I have the following code snippet
@trunkarray = split(/:/,$trunkid);
my $compString = "";
foreach $value ( @trunkarray ) {
print "<TR> <TD> $value </TD> </TR>";
if ( ! ($compString) ) {
$compString = "$value";
}
else {
$compString = $compString . ",$value";
}
}
&updateOperation($compString);
The $CompString
variable is sent to updateOperation
.
My script is giving a special character FS
(code point 28 or 0x1C) after the comma ,
along with $value
in the above statement. I found this special character's occurrence when I pasted the output in Notepad++.
Can anyone please tell me the reason why I'm getting this special character, and if there is a way to remove it?
Due to this special character, my database operation (under the updateOperation subroutine) is getting aborted; As this string is passed as an argument for an update operation like this:
sub updateOperation
{
my($trunkgrplist) = @_;
$UPDATE= "update TRUNKGROUP set source='D' where trunkgrpid in ($trunkgrplist)";
..
}
Upvotes: 0
Views: 579
Reputation: 385764
For whatever reason, you have the equivalent of
my $compString = "428331:\x{1C}428332:\x{1C}428333";
You can fix it with
$compString =~ s/\x1C//g;
or
$compString =~ tr/\x1C//d;
Your code becomes
sub updateOperation { # XXX Bad name
my @trunk_grp_ids = @_;
while (@trunk_grp_ids) {
my $trunk_grp_ids_list =
join ', ',
map $dbh->quote($_),
splice(@trunk_grp_ids, 0, 500);
$dbh->do("
UPDATE TRUNKGROUP
SET source='D'
WHERE trunkgrpid in ( $trunk_grp_ids_list )
");
}
}
my $compString = "428331:\x{1C}428332:\x{1C}428333"; # XXX Bad name
$compString =~ tr/\x1C//d;
my @trunk_grp_ids = split /:/, $compString;
updateOperation(@trunk_grp_ids);
Upvotes: 3