Alpesh Naik <naik.alp...@gmail.com> wrote:

> Hi Thomas,
> and thanks for the reply,
> 
> Given below is my code,
>
> #!/usr/bin/perl

#!/usr/bin/perl -w

=> You should always enable warnings.

> use strict;
>
> print "Content-type:text/html\n\n";
> use CGI;
> my $query = new CGI;

=> If you're using CGI, then you should use it everywhere.

use CGI;

my $query = new CGI;

print   $query->header() .
        $query->start_html();

> print "Name = ". $query->param('txtname')."<br>";
> print "No = ". $query->param('txtno')."<br>";
> print "Address = ". $query->param('txtaddress')."<br>";
> print "Designation = ". $query->param('txtdesig')."<br>";

my %cginame = ( 'Name' => 'txtname', 'No' => 'txtno', 'Address' => 
'txtaddress', 'Designation' => 'txtdesig' );
my @fieldorder = qw( Name No Address Designation );

print $query->start_p;

foreach my $field (@fieldorder){
  print $query->br( "$field = " . $query->param( $cginame{ $field } ) );
}

print $query->end_p;

> open (FILE, "+<data.txt") or die $!;
>
> while (<FILE>)
> {
>    if ($_ =~ m/^\s*+(name|no|address|Designation)/i)
>     {
>        our    $i = index($_,'=')+2;
>        $l = substr $_, $i;
>        push (@data,$l);
>     }
> }

=> this looks more like C than Perl. Please have a look at split().

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to