in reply to Problem with require()

A couple of problems.

First, don't end a require'd file with   return 1; Instead, just write   1; or   "hi mom"; or something. Any non-false, non-undef value will do.

Next, to avoid ambiguity (or, rather, to avoid getting tripped up by precedence), change   opendir UPLOAD,"$basedir/$name" or mkdir ... to   opendir(UPLOAD,"$basedir/$name") or mkdir ... or even better, write   mkdir "$basedir/$name", 0777 unless -d "$basedir/$name"; (and note that octal constants like 0777 require a leading zero).

Replies are listed 'Best First'.
learn() or die;
by chip (Curate) on Dec 19, 2001 at 12:09 UTC
    Forsooth, dws, you've given this poor petitioner exactly the wrong advice!

    Don't tell acolytes that opendir X,$x or die is dangerous because opendir lacks parens. To the contrary, the entire point of the "and", "or", "xor", and "not" keywords is that they have such low precedence that they are safe to use in just that fashion.

    Remember, being too cautious is just as likely to lead you into a mistake as not being cautious enough.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: Re: Problem with require()
by dakedesu (Scribe) on Dec 19, 2001 at 06:53 UTC

    That will teach me to apply C concepts to perl ;)... never knew I did not need the "return" keyword

    Thanks for your solution... I will make sure you get credit (I ALWAYS give credit)

    DakeDesu teh Confused Werewolf.
    Year Neo 3102
    (Webpages under construction)
      That will teach me to apply C concepts to perl ;)... never knew I did not need the "return" keyword

      And when is the last time you successfuly return'd from a #include'd file?

        That is not quite what I was getting at... but thanks for the new spin on how to look at it...

        I just used return, cause in PHP and C (yes, I will wash my mouth out with soap, if required) you did not need something at the end of a required file... I cannot remember the exact error message I got with my first require()'d file but I jumped to the conclusion (great exercise BTW) that I need return

        DakeDesu teh Confused Werewolf.
        Year Neo 3102
        (Webpages under construction)