Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Need help with syntax error in CGI script

by davidj (Priest)
on Aug 02, 2004 at 01:11 UTC ( #379162=note: print w/replies, xml ) Need Help??


in reply to Need help with syntax error in CGI script

If $query->upload('fullimage_file') || $query->upload('thumbnail_file' +) {
should be
if( $query->upload('fullimage_file') || $query->upload('thumbnail_file +') ) {
(The if is lowercase and parens were added)

Also the } on line 43 should be moved to line 27.

That is, instead of

if( $query->upload('fullimage_file') || $query->upload('thumbnail_file +') ) { my $img_name = $query->param('item'); my $full_pic = $query->upload('fullimage_file'); my $thumb_pic = $query->upload('thumbnail_file'); my $fullname = basename($full_pic); my $thumbname = basename($thumb_pic); my ($F_name, $f_ext) = split /\./, $fullname,2; my ($T_name, $t_ext) = split /\./, $thumbname,2; my $short_name="$img_name\.$f_ext"; my $short_tname="$img_name\_t\.$t_ext"; my $new_name = "$doc_root$img_folder/$short_name"; my $new_tname = "$doc_root$img_folder/$short_tname"; if ($full_pic ne ''){ open (OUTFILE,">$new_name"); binmode OUTFILE; while ($bytesread=read($full_pic,$buffer,1024)) { print OUTFILE $buffer; } } if ($thumb_pic ne ''){ open (FILE,">$new_tname"); binmode FILE; while ($bytesread=read($thumb_pic,$buffer,1024)) { print FILE $buffer; } } }
you should have
if( $query->upload('fullimage_file') || $query->upload('thumbnail_file +') ) { my $img_name = $query->param('item'); my $full_pic = $query->upload('fullimage_file'); my $thumb_pic = $query->upload('thumbnail_file'); my $fullname = basename($full_pic); my $thumbname = basename($thumb_pic); my ($F_name, $f_ext) = split /\./, $fullname,2; my ($T_name, $t_ext) = split /\./, $thumbname,2; my $short_name="$img_name\.$f_ext"; my $short_tname="$img_name\_t\.$t_ext"; my $new_name = "$doc_root$img_folder/$short_name"; my $new_tname = "$doc_root$img_folder/$short_tname"; } if ($full_pic ne ''){ open (OUTFILE,">$new_name"); binmode OUTFILE; while ($bytesread=read($full_pic,$buffer,1024)) { print OUTFILE $buffer; } } if ($thumb_pic ne ''){ open (FILE,">$new_tname"); binmode FILE; while ($bytesread=read($thumb_pic,$buffer,1024)) { print FILE $buffer; } }
making those changes will at least get it to compile (with some warning). Whether it runs correctly or not is another matter.

davidj

Replies are listed 'Best First'.
Re^2: Need help with syntax error in CGI script
by ysth (Canon) on Aug 02, 2004 at 05:34 UTC
    Moving the line 42 } is not a good idea; then the scope of all those lexicals doesn't extend to where they are actually used.
      Maybe his code that I downloaded was corrupted, because moving the } is the only way I got it to compile.

      davidj

        Huh; just changing the If to if and adding parens on that line makes it compile for me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2023-09-26 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?