Perl code to convert from CSH to BASH??



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



Relevant Pages

  • Re: Perl code to convert from CSH to BASH??
    ... I wrote the part of Perl code like that ($a is holding the line to be ... Remember that converting the "set path" statement isn't the only thing you need to. ... I don't know csh but I know at least that you'll need to convert the shebang, and probably a whole lot of other lines as well. ...
    (comp.lang.perl.misc)
  • Re: How to verify specified signature in .NET using RSA
    ... First, you can see that they are taking the signed token and directly converting it to binary using Base64, so the method I suggested for that is definitely the right approach. ... If you can provide the data you use to import the RSA key into the .NET algorithm, we can also try to compare it to the OpenSSL version to make sure there is no conversion problem. ... you need to be sure OpenSSL is using SHA1 since no parameter is provided in the PERL code and a default implementation is being used. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Processing files in Multiple directories (Bash or Perl?)
    ... I have a perl code, ... Now I would like to execute this code ... As I am new for both Bash and Perl, ...
    (perl.beginners)
  • Using perl code in K and C shell
    ... I need to used some perl code in k and C shell. ... substitution. ... Same code works fine in bash. ...
    (perl.beginners)