You're asking where/how $file is being read: If you read the CGI.pm docs, CGI.pm saves the uploaded file to a temp file and returns $file as a
filehandle to that temp file. The docs also say that if you use $file as a scalar, it returns the
filename of the original file. Which is why you should be able to pull out the filename to $fileName, and then continue to use $file when you read the file, assuming the filehandle is being created and passed correctly.
question, which may or may not be related: are you accessing this subroutine from within the your module or from outside your module? if from within, how are you calling this function? I'm just wondering why you need to pass the object (i.e.
my $self=shift;) if you never need $self. Unless, of course, this is the routine you are accessing from outside the module. It's just that I think that perl writing convention recommends that a subroutine with a name that begins with an underscore (i.e. "_file_upload") indicates an internal routine. Just a convention, though, not a rule. But it may confuse people who are used to the convention, plus I'm just trying to make sure you're not unexpectedly chopping off the first parameter you pass to this routine (depending on how you are calling it).
Doesn't answer your question, but I was hoping to help with the insight.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.