post value in perl cgi and HTML not inserting properly -


i new perl , using perl in end script , html in front end , cgi framework . reading details flat file , displaying them . trying print details in form of checkboxes. using use data::dumper; module check values . input value of last checkbox has space shown below

 print '<form action="process.pl " method="post" id="sel">';  print '<input type="checkbox" onclick="checkedall()">select all<br />';  foreach $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 selected value retrieved using

   @server = $q->param('sel'); 

but response of selection

 print "response " . dumper \@server; => showing [ 'ar', 'br', 'cr ' ];  

showing additional space after cr . dont know whats wrong .

in flat file have

rmclist:ar:br:cr  

i reading details array , splitting using

  foreach $ln (@lines)    {    if ($ln =~ /^rmclist/)   {  @robos = split (/:/,$ln);  }  } #### end of statement  shift (@robos);  print "the robos ", (join ',', map { '"' . $_ . '"' } @robos), "\n"; 

this showing robos are:

"ar","br","cr " 

while reading file @lines, forgot remove newline. newline interpreted simple space in html document.

remove newlines chomp function like

chomp @lines; 

before looping on lines.


actually, don't read file array @ all, unless have access each line more once. otherwise, read 1 line @ time:

open $infile, "<", $filename or die "cannot open $filename: $!"; @robos; while (my $ln = <$infile>) {     chomp $ln;      @robos = split /:/, $ln if $ln =~ /^rmclist/; } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -