I've been programming Perl for years, but am pretty much "just a programmer". I don't know much about shell scripts or working directly with the operating system, but recently when Schwern posted a small shell script for building a simple project shell without h2xs, I started playing with it. After it got to 100+ lines, I had a full-blown project building tool that created stub modules, set up tests the way I wanted them, added all of my helper utilities and optionally checked things into CVS.
Then I started converting it to Perl, because no one uses shell scripts anymore, right?
I took it as an article of faith that shell scripts weren't necessary, but I've quickly discovered that, if I am willing to sacrifice portability, shell scripts are shorter and easier than Perl. Now I'm creating them at work for small tasks and, if I knew sed or awk, I could possibly even skip the nasty parts where I fire up a Perl interpreter for heavy data munging. More stuff to learn, more stuff to learn, more stuff to ...
Whenever I write shell scripts, I always miss the ease of manipulating filenames and dates and times that I get in Perl. While I can see how you can save a few keystrokes performing some tasks in shell over Perl, like copying files and the like, I don't see any big wins in brevity with shell over Perl.
Also, I believe, although I've not actually checked, that Perl startup is not that much worse than awk or sed. There are some small number of awk or sed startups that are larger than a single Perl startup.
Some things lend themselves to shell scripts, sure, but in my admittedly limited experience, not many.
Re:shell scripts
Mr. Muskrat on 2004-01-16T08:33:10
10?!?? If I hit 5 lines, I start looking to Perl. If it's less that 5 lines, I generally try to refine it to the point that it will work as an alias.Re:shell scripts
Dom2 on 2004-01-17T09:07:10
If you use zsh, you can get quite a lot done in those 5 lines. Of course, it makes obfuscated perl look like a model of sanity.-Dom
Bourne shell is lovely. However, as someone who has written a lot of shell and Perl over the years, I use shell only for very short scripts indeed -- or when the script must run on a system that may not have Perl installed.
Many times I've started with a shell script, seen it grow to 50 lines, then 100, then
As for shell being shorter, I've found that not to be the case
I look forward to interest to Tim Maher's upcoming book to see his take on this.