in reply to return from subfunction

In the real code, what will you do when you detect a failure?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: return from subfunction
by fidesachates (Monk) on Apr 07, 2011 at 18:46 UTC
    Depends. This code is in my "Common.pm" module which I keep common subroutines I write. So anything under the sun I suppose.

    If it helps answer your question, the subroutine takes in a folder and a file. It returns various statuses depending on if the folder is writeable, readable, the combined path is used, not used... you get the idea.
      It returns various statuses depending on if the folder is writeable, readable, the combined path is used, not used... you get the idea.

      So the negative failure values mean readable or writable etc? What does the successful string represent?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        The successful string is the full path with the folder and the file name provided combined. The negative values, as you said, provide states when the combined path is not useable. Some states are: folder provided doesn't exist, folder isn't writable, folder isn't readable, filename in the folder already exists, and whatever else I thought up of (pretty sure that's it though. I wasn't that inventive).

        I appreciate you getting to know my code, however, I suspect the answer you are about to provide may be specific to this scenario. While that would be appreciated and taken into consideration, I would also like an answer to the question in the general sense as well. Any help, tip, or lesson is appreciated frankly.