Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Reactionary Coding?One-Shot Programs

by ariels (Curate)
on Jun 17, 2001 at 15:56 UTC ( [id://89153]=note: print w/replies, xml ) Need Help??


in reply to Reactionary Coding—One-Shot Programs

The "extreme" (no pun or reference intended!) example of this would be writing "one-liners" -- running perl -[np] -e ... from your command line. I use that for massaging data files and for extracting simple statistics. Sure, I could modularise the statistics and write it just once, but looking up the exact interface for a counter-that-also-keeps-average-value will take longer than recoding it. Maintainability isn't an issue here: if you're asking a question about a log file in order to find out if it's an interesting question at all, you're most likely going to decide you don't care about the answer.

Similarly, we sometimes run programs for days on end, only to discover a small bug in output. We'll fix the bugs, no question, but we don't want to lose the CPU time. If a small script can fix the output, we want it! (However, as tilly points out above, you can only do this if you've a backup; perl -pi.bk -e ... is invaluable here). The "patch" code will never run again, as the bugs in the program have been fixed -- it only exists to correct a single output file!

This is bioinformatics: some of our files are >1GB in size, so text editors are not an option; it's either sed, awk or Perl.

In both cases, you want to write code iteratively (the first 5 versions never work), run it once, and throw it away.

Of course, I always hide away a copy of the script in my home directory; I never know when I'll want to steal some stuff from an old script.

Replies are listed 'Best First'.
Re: Re: Reactionary Coding?One-Shot Programs
by John M. Dlugosz (Monsignor) on Jun 18, 2001 at 01:50 UTC
    I think there could be an intermediate form, or something for "one line programmers in training". That is, a small editor window or a button on your general editor to say "run it NOW" without having to make up a file name and save it, but still be able to easily edit and retry.

    Perhaps a perl script that when run from the command shell, pops up this window and saves the stuff in a temp file implicitly; output when 'run' goes to the same shell window (and context) that you started from. Run it again and you get a window that remembers the contents from last time, so you can alter and try again. Maybe I'll play around with that and post it if I come up with something worth keeping.

    —John

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found