RE: Javascript and perl



Hi,

Umesh T G <umesh.perl@xxxxxxxxx> wrote:
> Below is my index.pl

Some comments:

> #!/usr/bin/perl

# consider using -T fpr taint mode
use strict;
use warnings;

# consider using the CGI module, too.

> use Env;
> print "Content-Type: text/html\n\n\n";

One \n too many.

> chdir("/path/to/dir");

Always check the return value of a syscall.

> @files=`ls -1`; ## load all the html files..
>
> print "<html>\n";
> print "<head>\n";
> print <<END_SCRIPT;
> <script>
> function submit_form()
> {
> document.show_files.submit();
> setTimeout(\"document.show_files.reset()\",3);
> }
> </script>
> END_SCRIPT

You should really put all static parts of your page into a here document
instead of mixing here documents and extra print statements. Also the
escapes for the double-quotes are not necessary.

> print "</head>";
> print "<body>\n";
> print "<FORM NAME=\"show_files\" ACTION=\"display.pl\" METHOD=\"POST\"
> target=\"_blank\" onsubmit=\"submit_form()\" >"; print "<p>\n</p>";

That would also enable you to use quotes freely instead of having
to quote them. In any case, you should look up the qq() operator.

[...]

> This is my display.pl file...
>
>
> #!/usr/bin/perl
>
> &parse_form_data (*simple_form);

use CGI; instead.

HTH,
Thomas
.



Relevant Pages

  • Re: Is there a perl equivalent to PHP variables $_POST and $_GET?
    ... It would be easy to create, but what you really want is the CGI module: ... use strict; ... use warnings; ...
    (perl.beginners)
  • Re: counting question.
    ... because of the use strict above, you need to declare all variables ... is better but still does not deal with urlencoded params. ... again look at CGI module ... I dont get it. ...
    (comp.lang.perl.misc)
  • Re: Perl 5.8 and MD5
    ... use the methods provided by the CGI module. ... use strict; ... use CGI::Carp qw(warningsToBrowser fatalsToBrowser); # used while ...
    (comp.lang.perl.misc)