Perl code to convert from CSH to BASH??
- From: Ahmad <ahmad.abdulghany@xxxxxxxxx>
- Date: Sun, 27 Jan 2008 00:56:13 -0800 (PST)
Hi,
I was trying to write a Perl code to be used to convert CSH scripts to
BASH. I target to translate .cshrc file to .bashrc one.
My question is: In converting "path" setting statement i was trying
to use "join" and "split" functions.
For example:
set path = (/bin /usr/bin /sbin $HOME/bin ) ===> export PATH=$PATH:/
bin:/usr/bin:/sbin:$HOME/bin
I wrote the part of Perl code like that ($a is holding the line to be
converted):
$a=~s/[()]//g ; # To remove parentheses
$a=~s/set\s+path\s+=(.+)/export PATH=\$PATH:/g;
$b=join(':',split(/\s+/,$1);
$a.=$b;
print FID $a;
And it worked fine, but as you see, the code is very long to convert a
very small part.. Is it possible to include and evaluate function
within the RE replacement side?
Something like that: $a=s/....../....FUNCTION TO BE EVALUATED (e.g.
join.....)..../eg;
How can i do it?
Thanks a lot in advance,
Regards,
Ahmad
P.S. If anyone knows an easiest way to convert from csh to bash, or
had already written a script that does that, please tell me about it..
Thanks a lot.
.
- Follow-Ups:
- Re: Perl code to convert from CSH to BASH??
- From: Henry Law
- Re: Perl code to convert from CSH to BASH??
- Prev by Date: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
- Next by Date: Regexp to search over several lines in one string
- Previous by thread: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
- Next by thread: Re: Perl code to convert from CSH to BASH??
- Index(es):
Relevant Pages
|