in reply to Use Strict & subs

A more general comment: if you are going to use CGI, you should take advantage of the functionality that it offers you. First, you should create a CGI object by saying my $q = CGI->new. Then your input parsing line would look like my $PDFFile = $q->param("file"); and you don't need any variables like $INPUT or %INPUT. You also don't need DecodeInURL - just get rid of it. Furthermore, instead of print "Content-type: text/html\r\n\r\n"; you could simply use print $q->header("text/html");. Finally, though you may know this already, I should point out that the call to system does not return the output of the "pdf2jpeg" command, but rather its exit code, which is just a number. So this number is what will be displayed on the line that says "Output:" I'm not sure how exit codes work in Windows, but in Unix, and exit code of zero means success.

Replies are listed 'Best First'.
Re^2: Use Strict & subs
by jbrugger (Parson) on Dec 30, 2004 at 07:23 UTC
    Just a little comment.
    i'd be careful using CGI, this module is a real good hack, but BIG (using 3,5 mb of your memory when compiled).
    Next, i don't really like the idea of using the html stuff CGI offers, i like my perl code to be perl, not html. You might Have a look at HTML::Template, or try the Tal implementation for perl: Petal.
    I don't want to create a flame about CGI versus other methods (like Apache::Request), but i'd like to inform about the possibilities, since CGI might not be the best solution for some problems.

    hmm updated since last comment:
    I'd use either the module HTML::Template or Pental (the Plone template system) to conform more to the Model-View-Controller patterns, and use templates and these modules to generate the html-content in stead of CGI

    Next i'd use the Apache::Request implementation to read any requests, it has the same interface as CGI, but is light and fast in use.
    More information can be found on http://www.cpan.org and www.plone.org.
      While technically true, your comment would be better suited if you explained further why someone should use HTML::Template instead of CGI. Furthermore, what is a "Tal" implementation?

      For the record, I know what those things are. But, you're giving an answer to someone who doesn't seem to have a lot of domain experience in the web applications world. You need to explain what you're talking about and why someone should make a radical paradigm shift.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      i'd be careful using CGI, this module is a real good hack, but BIG (using 3,5 mb of your memory when compiled).

      It's worth pointing out that whilst it's true that CGI.pm contains a lot code, it also implements a pretty ingenious code loader that it only actually compiles the code that you use. So you shouldn't really worry about loading code that you aren't going to use - CGI.pm is actually pretty efficient.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg