LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-12-2006, 07:58 AM   #1
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Rep: Reputation: Disabled
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?
 
Old 09-12-2006, 08:27 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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.
 
Old 09-12-2006, 09:42 PM   #3
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 719

Rep: Reputation: 72
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:
Quote:
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.
http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q5.19.html
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 )

Last edited by makyo; 09-13-2006 at 05:16 PM.
 
  


Reply

Tags
conversion, perl, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert while(<>) from perl to python bardinjw Programming 2 04-13-2006 09:21 AM
Convert shell scripts to other language vladmihaisima Programming 6 07-28-2005 03:25 AM
bash & perl scripts scribbler001 Programming 1 04-26-2005 05:56 AM
Howto convert Gentoo wlan scripts to Debian? Naughtyus Debian 1 02-25-2004 04:55 PM
How to Run perl scripts using bash Boudewijn Linux - Software 2 11-26-2003 04:37 AM


All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration