rudra <bnrj.ru
...@gmail.com> wrote:
> Dear friends,
> I am facing a herculian job of renaming 506 fortran routine and 4000
> 'call' made by them.
> what i have to do is to change
> subroutine some_name(lots of arguments)
> to
> subroutine b_some_name(lots of arguments)
> and
> call some_routine(arguments)
> to
> call b_some_routine(argument)
> i.e. add a prefix in front of every call/subroutine!
> they are not in any specific position. Can i do it using bashscript?
> I have an idea that sed/awk may be able to do that. but how? any help?
Here's something I cobbled together quickly (so no guarantees that
it works correctly;-) for Perl
------------8<-----------------
#!/usr/bin/perl
use strict;
use warnings;
my $suffix = "b_";
my $buf;
$buf .= $_ while <>;
$buf =~ s/\b(subroutine|call)(\s+)(\w+)(?=\s*\()/$1$2$suffix$3/gi;
print $buf;
------------8<-----------------
Replace the "b_" behind "my $suffix =" with what you really want
to prepend to the function names, store it in a file, e.g. named
'fortconv' and then do
perl fortconv < old_file.f > new_file.f
and you're hopefully done.
Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de