ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm trying to choose a scripting language for a project here at work. I have a few requirements:
- easy-to-use argument handling features (script --option --option, etc.)
- robust text processing (writing out text files, inserting values into existing files, etc.)
- relatively simple to get off the ground for a semi-experienced programmer (with no OO xp)
I have a few languages to choose from:
- perl
- python
- tcl
- common shells
Unfortunately, I can only use these, since they are the ones installed on the systems here, and this script will be passed around, etc.
someone asked abuot the exact same thing a few hours ago, but for the record... Perl. thing is that a moderate level of Bash (i.e. shell) should really be a given. at advanced levels the world is almost your oyster, but it's never *quite* as comprehensive as a full scripting affair like perl or python.
perl has erm.. 4 different command line argument modules... getopts::short ::long and others... python or perl... your are so so so unliekly to find soemthign they can't do at this stage. perl even comes with webserver modules and all sorts of weird stuff. command line handling is a pretty trivial thing at the end of the day.
I'd also add that if you go with a shell language like bash, you may have more portability (since practically every Linux install has bash; they don't always come with Perl or python), in exchange for slightly less power and versatility. Most text processing from bash will most likely have to be achieved via other standard utilities such as grep or sed, whereas with Perl it can be done more directly. And if you need to do any kind of arithmetic (other than integer), bash is probably not the right choice.
Bash has the builtin "getopts" command for parsing command-line options, and it's also fairly easy to just use a while-loop with a nested conditional statement to retrieve arguments, executing a "shift" after each to bring in the next argument.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.