i am new to Perl and using Perl in my back end script and HTML in front end and CGI framework . Initially i am reading some details from flat file and displaying them . I am then trying to print the details in the form of checkboxes. i am using use Data::Dumper; module to check the values . however my input value of the last checkbox has an extra space as shown below
print '<form action="process.pl " method="POST" id="sel">';
print '<input type="checkbox" onClick="checkedAll()">Select All<br />';
foreach my $i (@robos) {
print '<input type="checkbox" name="sel" value="';
print $i;
print '">';
print $i;
print '<br />';
}
print '<input type="submit" value="submit">';
print '</form>';
print "response " . Dumper \$data;
however in Process.pl the selected value is retrieved using
@server = $q->param('sel');
but the response of selection is
print "response " . Dumper \@server; => is showing [ 'ar', 'br', 'cr ' ]; which is
showing an additional space after cr . I dont know whats is wrong .
In my flat file i have
RMCList:ar:br:cr
i am then reading the details into an array and splitting using
foreach my $ln (@lines)
{
if ($ln =~ /^RMCList/)
{
@robos = split (/:/,$ln);
}
} #### end of for statement
shift (@robos);
print "The robos are ", (join ',', map { '"' . $_ . '"' } @robos), "\n";
This is showing the robos are:
"ar","br","cr
"
@robos
– have you tried looking at that data? Note that you should escape your dumps:use HTML::Entities;
, thenprint encode_entities Dumper \@robos
. – amonprint "The robos are ", (join ',', map { '"' . $_ . '"' } @robos), "\n"
– amon