SPUG: generating output with a cgi script

Matt Tucker tuck at whistlingfish.net
Mon Oct 2 16:14:05 CDT 2000


-- "Wu, Yaoxi" <yaoxi.wu at attws.com> spake thusly:

> #!/usr/bin/perl -wT
> use CGI;
> $cgi = new CGI;
> print $cgi->header("text/plain");
> open(DB_FILE, "test.bib");
> undef $/;
> $line=<DB_FILE>;
> close DB_FILE;
>
> #### the following was displayed o.k. ##########
>
> print "Any string.\n";
> print $cgi->param('source_type'),"\n";
>
> #### the following did not show up in the web browser window ###
>
> print "$line\n";
> foreach $name ($cgi->param){
>        print "$name:\n";
>        foreach $value ($cgi-param($name)){
>        print " $values\n";
>        }
> }

The first thing I noticed is that the foreach $value line has 
"$cgi-param($name)". I assume this a typo, and is correct in the script 
itself? If not, then it's likely the cause of that part of the problem.

As for the DB_FILE not printing, I'm guessing it's a permission issue. 
You should always check the return value of system calls like that, as 
in:

    open(DB_FILE, "test.bib")
        or die "Couldn't open file 'test.bib' for reading: $!\n";

Hope this helps.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20001002/fc670bdc/attachment.bin


More information about the spug-list mailing list