in reply to Conditional statement problem

Simple problem: Even though sometimes $to_set isn't set, you're always passing it to header().

Easy fix: Use an array @to_set instead:

@to_set = (-cookie => cookie(-name => $name, ...)); # ... print header(@to_set);

For extra future expansion points, use push() instead of array assignment.

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re: Re: Conditional statement problem
by Anonymous Monk on Nov 14, 2001 at 20:13 UTC
    Thanks for your reply, Chip. It turns out the problem was in my statements to print the image. For some reason they'd only work if the cookie was also set but not if it wasn't. I replaced the last three lines with the following and it works now. I don't have enlightenment but I do have results, so I'll go with that.
    my $image = 'logo.gif'; open(IMAGE, "<$image") or die "cannot open image file: $!"; my $no_bytes = (stat ($image))[7]; print "Content-type: image/gif\n"; print "Content-length: $no_bytes\n"; print "Pragma: no-cache\n\n"; print <IMAGE>; close(IMAGE) or die "cannot close image file: $!";