-   Programming (
-   -   convert bash scripts to Perl (

noir911 09-12-2006 06:58 AM

convert bash scripts to Perl
I'm planning to convert most of my system related scripts from bash to Perl. I looked at the book - Perl for System Administration and didn't find it very helpful. Most of the scripts over there are dependent on CPAN modules whereas I want to keep things simple without having to depend on CPAN modules. Is there any useful online resources where I can get Perl codes related to system administration?

acid_kewpie 09-12-2006 07:27 AM

what kind of modules? CPAN holds virtually all common perl scripts, these aren't unsual modules or anything. many of them will already be on your system, or prepackaged within rpm's or other formats for your packaging system.

makyo 09-12-2006 08:42 PM

Hi, noir911.

The success of the conversion probably will depend to a large degree on what it is that you're doing.

I remember thinking I should do the same thing. From an old FAQ on perl:

How can I convert my shell script to Perl? ...
Actually, there is no automatic machine translator. Even if there were, you wouldn't gain a lot, as most of the external programs would still get called. It's the same problem as blind translation into C: you're still apt to be bogged down by exec()s. You have to analyze the dataflow and algorithm and rethink it for optimal speedup. It's not uncommon to see one, two, or even three orders of magnitude of speed difference between the brute-force and the recoded approaches.
This is not to say that you can't or shouldn't, only that you may need to think about things. Sort of like "render unto the shell the things which are the shell's" (with apologies for the paraphrase to the Dictionary of Cultural Literacy).

Best wishes ... cheers, makyo

( edit 1: typo )

All times are GMT -5. The time now is 12:14 AM.