in reply to Reading form data and printing variables using CGI.pm

Greetings cal,

You're on the right track. You just need to define what $Firstname is going to be.

my $Firstname = param('Firstname');

Put that somewhere in front of your print statement and you're done.

-gryphon
code('Perl') || die;

Replies are listed 'Best First'.
Re: Re: Reading form data and printing variables using CGI.pm
by cal (Beadle) on Jul 19, 2002 at 21:23 UTC
    But how does the variable become associated to the HTML line? 'is the value of $Firstname', Thanks
    <code> #!/usr/local/bin/perl -w use strict; use diagnostics; use CGI qw(:standard); my $Firstname = param('Firstname'); print header(), start_html(-title=>"CGI.pm Example Script"), h1('Hello World!'), 'is the value of $Firstname', end_html(); exit (0);

      Greetings cal,

      In Perl, using a single quote simply reads a string literally, but a double quote interprets a string. In your code, you have single quotes around the string where you use $Firstname. So what gets printed is literally "$Firstname". You actually want Perl to interpret the variable, so...

      print header(), start_html( -title => 'CGI.pm Example Script'), h1('Hello World!'), "is the value of $Firstname", end_html();

      -gryphon
      code('Perl') || die;

      Huh?
      my $PERL_FAQ = "butterscoth"; print 'my $PERL_FAQ \n'; print "my $PERL_FAQ \n";

      ____________________________________________________
      ** The Third rule of perl club is a statement of fact: pod is sexy.