Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Append to file or create file depending on input filename.

by markuhs (Scribe)
on Nov 23, 2009 at 10:46 UTC ( #808781=note: print w/ replies, xml ) Need Help??


in reply to Re: Append to file or create file depending on input filename.
in thread Append to file or create file depending on input filename.

Thanks, ++graff!
Sometimes, user-friendliness or rules from above(/before you were there) do not allow you to do what you want. I need to have the output file as option on the command line. Most users do not want to bother with shell stuff and some are very inexperienced... -> My achievable elegance is drastically limited/controlled... ;-(


Comment on Re^2: Append to file or create file depending on input filename.
Re^3: Append to file or create file depending on input filename.
by graff (Chancellor) on Nov 24, 2009 at 04:22 UTC
    Well, if a primary objective is to protect simple-minded users from the complexities of the shell, you really should avoid using angle brackets on the command line altogether.

    To put that another way, if users don't want to be bothered with the standard usage of angle brackets, things will go much better for all concerned if you simply forbid any use of angle brackets.

    Why? Because when you forget to use quotes in OP approach to appending, you can get in bad trouble. REALLY Bad Trouble. As in, deleting the very data you were supposed to preserve by appending.

    So do it like this:

    Usage: script_name [-a] output_file_name by default, output_file is created as a new file use "-a" to have output appended to existing output_file
    That is, use "-a" instead of an angle bracket. Or better yet (assuming that it's more important to avoid deleting existing data), make appending the default mode of operation, and have an option "-n" (for "new") or "-b" (for "begin" or "blank-slate") or whatever, to create/truncate the output file.

    Rest assured, the OP design is the farthest thing from "user friendly". You have to do better than that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2014-12-19 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (92 votes), past polls