Dear Monks, It seems I have lost a variable. I'm writing a CGI that will upload image files provided through an HTML form, then resize them and place them in the appropriate files.
#!C:\Perl\bin\perl.exe -wT ## use strict; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser/; use File::Basename; $CGI::POST_MAX = 1024*5000; $CGI::DISABLE_UPLOADS = 0; my $query = CGI->new; my $safeCharacters = 'a-zA-Z0-9_.-'; my $uploadDirectory = 'C:/Apache/htdocs/notoriousteaze.com/Images/Temp +'; my $originalImage = $query->param("Image"); my ($filename, undef, $ext) = fileparse($originalImage, qr({\..*})); $filename .= $ext; $filename =~ tr/ /_/; $filename =~ s/[^$safeCharacters]//g; if ($filename =~ /^([$safeCharacters]+)$/) { $filename = $1; } else { error("That file name doesnt work for me. $filename"); } my $uploadFilename = $query->upload("Image"); open(UPLOADFILE, ">$uploadDirectory/$filename") or error('Could Not Up +load File.'); while ( <$uploadFilename> ) { print UPLOADFILE; } close UPLOADFILE; my %resizeFileType = ( ".jpeg" => \&resizeJpeg, ".jpg" => \&resizeJpeg, ".gif" => \&resizeGif, ".png" => \&resizePng, ); if(defined ($resizeFileType{$ext}) { $resizeFileType{$ext}->(); } else { error("Not seeing the filetype: $ext"); }
I'm not posting the subroutines because I never manage to reach them. I get stopped with "Not seeing the filetype: ", but $ext seems to be empty by the time I get there. I tried messing around with the scope of $ext (removing "use strict;" and "my"), to no avail. And yes, yes: I realize that I'm running with this on a Windows machine. Any help would be most appreciated. Thank you, kind monks. Cheers, K.

In reply to A Wayward Variable by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.