
swathi
New User
Sep 8, 2008, 9:36 AM
Post #1 of 2
(7814 views)
|
everythin works somewat fine in my code but the prob is once the count gets decremented when it is being written in the line it is written with extra new line plz resolve it it comes like seats.txt: 68 67 67 or seats.txt: 68 67 67 HEY THIS IS MY HTML FILE THAT LEADS TO THE PERL FILE: <html> <head> <title> PURCHASE FORM </title> </head> <body> <pre> <h3>KINDLY ENTER YOUR DETAILS FOR MBA COUNSELLING </h3> <form action="http://127.0.0.1/cgi-bin/reg.cgi" method="get" > <pre> ENTER THE ID: <input type="text" name="id"> </pre> <br> <pre>ENTER THE NAME: <input type="text" name="name"></pre> <br> <pre>ENTER YOUR ADDRESS: <input type="text" name="add"></pre> <pre>ENTER YOUR SPECIALISATION CODE: <input type="text" name="code"></pre> <pre> <input type="submit" value="Submit"></pre> <TABLE BORDER='2'> <th>CODE</th> <th>SPECIALISATION</th> <tr> <td>0</td> <td>finance</td> </tr> <tr> <td>1</td> <td>hr</td> </tr> <tr> <td>2</td> <td>economics and statistics</td> </tr> </table> </form> </body> </html> HEY THIS IS MY PERL CODE: #!C:\Perl\bin\perl.exe print "Content-type: text/html\n\n"; use CGI qw(param); print "<b>"; my $name = param("name"); print "Your name is $name\n"; print "<br>"; my $add = param("add"); print "Your address is $add\n"; print "<br>"; my $ran = int(rand(50)); print "Your id no is $ran\n"; print "<br>"; print "PLZ NOTE IT WELL"; print "<br>"; my $code = param("code"); chomp $code; if ($code eq "0") { print "Your specialisation is finance"; } if ($code eq "1") { print "Your specialisation is hr"; } if ($code eq "2") { print "Your specialisation is economics and statistics"; } print "<br>"; print "</b>"; my $filename = "numbers.txt"; open (my $fh, ">>", $filename) or die "Could not open ’$filename’\n"; print $fh "$ran"."$name"."$code\n"; my $file = "seats.txt"; open(my $fg, "<", $file) or die "Could not open ’$file’\n"; @input = <$fg>; close $fg; print (@input); if ($code eq "0") { $input[0] = $input[0] -1; } if ($code eq "1") { $input[1] = $input[1] -1; } if ($code eq "2") { $input[2] = $input[2] -1; } print (@input); open(my $fg, ">", $file) or die "Could not open ’$file’\n"; print $fg "$input[0]\n"; print $fg "$input[1]\n"; print $fg "$input[2]\n";
|