Greetings Bretherin,

I've currently been working on a online photo album "sort of thing". I'm using cgi scripts to do everything from generate pages to resizing images. its a large enough project for some one as inexperienced as me but I'm glad to say that its coming along nicely.
I've only had one main problem so far and thats been the file upload script. Seeing as I've never done one before or even seen one, I was bound to have trouble with it. I've been a while at it and I think I have it but...
Theres always a but!!!
Perl keeps throwing up these silly, confusing syntax errors and I'm stumped. I'm probably just not seeing whats wrong.
Also if you could tell me whether my way of uploading is, first of all, right and/or is there another "better" way to do this.


These are the errors Perl is giving me:
syntax error at upload.cgi line 18, near "%pics(" syntax error at upload.cgi line 36, near "@pic_filehandles(" syntax error at upload.cgi line 73, near "while <$pic_filehandles[$cnt +r]>" syntax error at upload.cgi line 80, near "}"

And heres the code
I've inserted a line of hashes just before the error lines just to save you counting.
#!/usr/bin/perl -w use CGI; $q = new CGI; my $album = $q->param("T1"); unless ( -d "./albums/$album" ) { mkdir( "./albums/$album", 0775 ) || die "Can't create $webpage_dir: ( +$!)\n"; } my $upload_dir = "albums/$album"; ############################################ %pics( pic0 => $q->param("photo") , pic1 => $q->param("photo1") , pic2 => $q->param("photo2") , pic3 => $q->param("photo3") , pic4 => $q->param("photo4") , pic5 => $q->param("photo5") , pic6 => $q->param("photo6") , pic7 => $q->param("photo7") , pic8 => $q->param("photo8") , pic9 => $q->param("photo9") , pic10 => $q->param("photo10") , pic11 => $q->param("photo11") , pic12 => $q->param("photo12") , pic13 => $q->param("photo13") , pic14 => $q->param("photo14") ); ######################################### @pic_filehandles( $q->upload("photo") , $q->upload("photo1") , $q->upload("photo2") , $q->upload("photo3") , $q->upload("photo4") , $q->upload("photo5") , $q->upload("photo6") , $q->upload("photo7") , $q->upload("photo8") , $q->upload("photo9") , $q->upload("photo10") , $q->upload("photo11") , $q->upload("photo12") , $q->upload("photo13") , $q->upload("photo14") ); strip_filename(); sub strip_filename{ my @allkeys = sort(keys(%pics)); foreach $key (@allkeys){ $pics{$key} =~ s/.*[\/\\](.*)/$1/; } } my $cntr = "0"; @files = sort(keys(%pics)); foreach $key (@files){ open IMAGE, ">$upload_dir/$pics{$key}"; binmode IMAGE; ######################################## while <$pic_filehandles[$cntr]> { print IMAGE; } close IMAGE; $cntr += 1; ############################################# } print $q->header ( ); print <<END_HTML; <HTML> #RANDOM HTML </HTML> END_HTML
I'm stumped so any and all help will be greatly appriciated.
All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.


In reply to Confusing Syntax by eoin

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.