in reply to Re^7: Clear the contents of the text file
in thread Clear the contents of the text file

You can't have a "self-contained test" if you are testing writing to a file. You need to write to the file. The shell commands showed the output of cat. The test showed exactly what the output indicated: If you pass append() an empty string, as shown in the spew() example I was replying to, you will get an error.

Who suggested passing an empty string as in the spew example?

That is the wrong way to try to use path()->append

And the reason to do this in the OP's case is not for file permission preservation, but for file locking.

The rest of the OPs program doesn't use advisory locking, so there is no benefit if Path::Tiny uses it

Therefore there is no benefit to using append at all

  • Comment on Re^8: Clear the contents of the text file

Replies are listed 'Best First'.
Re^9: Clear the contents of the text file
by 1nickt (Canon) on Jul 22, 2015 at 03:45 UTC

    >>>And the reason to do this in the OP's case is not for file permission preservation, but for file locking.

    >>The rest of the OPs program doesn't use advisory locking, so there is no benefit if Path::Tiny uses it

    From the OP:
    > Once those actions are completed i need to clear out the contents of the files so that nobody resuses those same contents when the action is taken on new set of servers

    Whatever. The OP can't figure out how to install P::T so truncate() is a probably a better option for him anyway.

    The way forward always starts with a minimal test.

      1nickt: From the OP: > Once those actions are completed i need to clear out the contents of the files so that nobody resuses those same contents when the action is taken on new set of servers Whatever

      In what way is that requirement enhanced by flocking when emptying the file?