Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^7: Clear the contents of the text file

by 1nickt (Canon)
on Jul 22, 2015 at 03:18 UTC ( [id://1135781]=note: print w/replies, xml ) Need Help??


in reply to Re^6: 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.

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

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^8: Clear the contents of the text file
by Anonymous Monk on Jul 22, 2015 at 03:35 UTC

    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

      >>>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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found