A
Ahmad
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.
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.