LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 01-02-2009, 09:09 AM   #1
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Rep: Reputation: 31
bash to perl


Is there any software available which will convert a bash script to perl? Are the two that similar? My bash script basically makes a text config file based on the answers to some questions.

Cheers guys.
 
Old 01-02-2009, 09:19 AM   #2
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
Try searching for it.
 
Old 01-02-2009, 09:25 AM   #3
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
From what I understand, you can't really do this (beyond the simplest, most hackish surface level). A shell script is normally a wrapper - a little syntax that calls a bunch of external commands (grep, echo, gawk, sed, cat, etc.). To really rewrite that in Perl - both the syntax and the external commands - you need a human.

Also, in the process, you would almost certainly want to write it to Perl's strengths - ie, rethink the methods, data structures, algorithms, etc. Again, that would need a human.

Edit: see this link, which seems to have a post from our very own Chrism.

Last edited by Telemachos; 01-02-2009 at 09:27 AM. Reason: Added a link to a PerlMonks posting
 
Old 01-02-2009, 06:01 PM   #4
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
I love it when people say "try searching" then present a google page with 900forums all with the same problem - thanks for that, I'd not even thought of using a search engine prior to writing this post. Unihiekka can you please refrain from the sarcastic useless belittling elitist crap in future.

Telemachos I'd read about sh2p but I also read somewhere it was a joke In fact on the page you showed me; the last comment describes it being an april fools joke and puts the entire code inside a system call. It's probably a bad idea using a conversion tool anyway, I've never had much luck with them.

I guess it's time to learn perl Thanks for your help.
 
Old 01-02-2009, 06:09 PM   #5
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
Quote:
Originally Posted by genderbender View Post
I'd read about sh2p but I also read somewhere it was a joke In fact on the page you showed me; the last comment describes it being an april fools joke and puts the entire code inside a system call. It's probably a bad idea using a conversion tool anyway, I've never had much luck with them.
I didn't give the link to suggest you use sh2p, but to show you that many experienced Perlistas (?!) say that it takes (a great deal of) human intervention to turn shell scripts into Perl.

As for learning Perl, take a look here: http://www.perl.org/books/beginning-perl/
 
Old 01-02-2009, 06:12 PM   #6
genderbender
Member
 
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
Gotcha - cheers mi dears. I think I have an Oreilly book somewhere, thanks for the links Tasks like this are usually good ways to introduce yourselff to programming languages anyway. Once again, thanks for the advice, much appreciated.
 
Old 01-03-2009, 10:01 AM   #7
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.
Quote:
Originally Posted by genderbender View Post
... I'd read about sh2p but I also read somewhere it was a joke In fact on the page you showed me; the last comment describes it being an april fools joke and puts the entire code inside a system call. It's probably a bad idea using a conversion tool anyway, I've never had much luck with them ...
Minor comment: my reading of the post by Schwartz (http://www.perlmonks.org/?node_id=577182) is that it was the first entry (Oct 09, 2006). There is a recent (9th October 2008: Now on version 0.04 and have gone beta) entry in CPAN by the author as noted in the update section of the main post. I looked at it on CPAN briefly, but have not tried it, however.

Clive Darke, the author, writes: It does not attempt to redesign the script for Perl but to assist in the conversion process by automating much of the tedium.. That might make it useful for some conversion tasks ... cheers, makyo
 
Old 01-04-2009, 07:37 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
... and here's the complete Perl lang docs, with tutorials: http://perldoc.perl.org/. A good supplement to the Llama book (Learning Perl): http://en.wikipedia.org/wiki/Learning_Perl
See also http://www.perlmonks.org/?node=Tutorials
 
  


Reply



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
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
bash under perl Braynid Programming 8 11-23-2007 03:16 AM
bash perl elvis Linux - General 9 04-22-2005 05:41 AM
Bash or Perl? philipina Linux - General 3 07-27-2004 06:52 AM
perl/bash sk8guitar Programming 5 07-14-2003 01:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:08 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
Open Source Consulting | Domain Registration