in reply to Re: Java Repackager...
in thread Java Repackager...

So is it reasonable to replace the foreach loop with
a call to perl, containing:

`perl -i -pe 's/^(import\s+)$oldPackage/$1NewPackage/' *.java`; print "Updated:\n"; print join( "\n", <*.java> );

I'm wary of calling perl inside perl, because I have
no idea what really happens (is a new perl interpreter
spawned? Are there Really Bad side effects? etc.)
So tell me! Inquiring minds want to know...

Rob

Replies are listed 'Best First'.
Re3: Java Repackager...
by IlyaM (Parson) on Nov 27, 2001 at 22:26 UTC
    My point was that you can replace whole script with this one-liner.

    If you will embed it into some bigger script than it will do cause new perl interpreter to spawn. As for Really Bad side effects: it will be perfomance hit (but you should not care about it in this case) and probably it is not very good style. At least I would not embed such one-liner in my Perl code myself because IMHO embedding Perl code inside Perl code looks somewhat ugly.

    Probably foreach loop could be written slightly shorter but in general your original script is ok. I just wanted to show fast dirty way to do the same.

      Thanks for the clarification.

      The script was written for a colleague who knows neither
      perl nor regexps; therefore, the outer scaffolding is
      necessary. However, your comment stands: the performance
      hit just doesn't matter in this case, it's true.

      Rob