in reply to Re (tilly) 6: Quick Regex question
in thread Quick Regex question

Hey Tilly, I tried it, but all I could get was internal server errors. Is HTML::Entities part of the standard perl distribution? I don't have a clue why it won't work.

Replies are listed 'Best First'.
Re (tilly) 8: Quick Regex question
by tilly (Archbishop) on Jan 14, 2001 at 18:29 UTC
    HTML::Entities is off of CPAN so you may not have it. Sorry for not checking. For a quick test you can make the following modification:
    --- files.pl Sat Jan 13 11:31:40 2001 +++ files2.pl Sat Jan 13 20:51:31 2001 @@ -1,7 +1,6 @@ #! /usr/local/bin/perl -T use strict; use CGI qw(:standard upload); -use HTML::Entities; print header(), start_html('Upload Test'), h1('Upload Test'), start_multipart_form(), "Enter how many files to upload: ", textfield("filecount"), br(); @@ -19,6 +18,11 @@ next; } print p(), h3("Uploaded $handle"), br(), "<pre>"; - print encode_entities($_) while <$handle>; + while (<$handle>) { + s/&/&amp;/g; + s/</&lt;/g; + s/>/&gt;/g; + print; + } print "</pre>"; }
    (The solution with the original module is able to handle unexpected input better though.)

    Also it sounds like you have not yet discovered your server error logs. If you are on a Unix-like system it will be something like /var/log/apache/error.log. When you get these internal errors the tail of that will have all sorts of useful information. In similar vein you should try running the CGI script interactively, that can identify many problems.

    Several other good tips are here - highly recommended despite the name. (A little dated now, but good advice nonetheless.)

      Hey Tilly, I got the script to work now (Idiot is the word. I was so tired last night I forgot to set permissions. Duh!). Where is it placing the images though?
        In this script nothing is done with uploaded files except echo data back to screen. Where I am reading from $handle you would need to open up a file, and print that. You will need to open a file to print to, if you are on windows binmode one or both filehandles (dunno off of the top of my head nor do I have Windows to test with), then:
        my $buffer; while (read($handle, $buffer, 10240)) { print IMAGE $buffer; }
        to write it out.