[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: what is perl 's syntax or grammer?(toward e-commerce)



eric lin <fsshl@centurytel.net> writes:
>    I follow two boods, one is "HTML for the World Wide Web with XHTML
>    and CSS" the other is "Teach yourself WEbPublishing with HTML and
>    XHTML"
>
> may be best weblanguage is java or java script, let me explore html
> and cgi and perl first

(Disagreeing with Colin Watson, I actually do like Java as a
language.  I agree that JavaScript is to be avoided whenver possible,
though.  The Java runtime still feels pretty heavy-weight to me; I
wouldn't try writing CGI scripts in it, for example.)

> -----------------------------------------my entrance.cgi--------------------
> #!/usr/bin/perl
> use strict;
> use CGI ':standard';
>
> my @param=param();
>
> print "Content-type: text/html\n\n";
> print "<html><body>\n";
> print "This is an example CGI script.\n";
>
> foreach my $name (param()) {
>    my @value = param($name);

Are you sure you don't mean $value here?

>    print "<p>The field with the NAME attriabute equal to <b>
>    $name</b> had a VALUE equal to <b>@value</b></p>\n";

...and here?  I'd probably change this loop to something like

  foreach my $name (@param) {
    print "$name: " . param($name) . "\n";
  }

>    }
> print "</body></html>";

If you're lost on basics of Perl (e.g. what $, %, and @ mean before
variable names, how $foo, $foo{bar}, %foo are related, etc.) you might
want to spend a lot of time reading the Perl documentation, and/or
buying one of the O'Reilly Perl books if you're into dead trees.  'man
perlintro' might be informative, along with reading some of the other
man pages listed in 'man perl'.  Also, to get documentation on a
specific Perl package, you can do e.g. 'perldoc CGI'.

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: