Assuming the Example is Just an Example

Maybe I read between the lines a little too much but my guess is that your example is just that, an example, and you really are asking how to avoid recompiling code and repeatedly invoking Perl. The answer to that is likely a process (crude but effective):

use strict; use Daemon::Easy sleep=>5, stopfile=>'stop', pidfile=>'pid', callback= +>'worker'; use File::Find qw~find~; run(); sub worker { die 'Improper setup -- must have an ./old folder!' unless (-d './old +'); die 'Improper setup -- must have a ./pass folder!' unless (-d './pas +s'); find(\&wanted, qw~/tmp/working/perlmonks/lib/11156715~); } sub wanted { if ( (-f $File::Find::name) && ($File::Find::name=~m/\.pl$/ ) && ($File::Find::name !~m/code\.pl$/) ) { print "open the file, replace comments, resave orig. to ol +d folder and updated one to pass folder --- $File::Find::name\n"; } }

Errr....you can do this in like a bazillion other ways in Perl. Off the top of my head you could use Dancer or Mojolicious or just hack up an HTTP server, etc.

Otherwise...

Here is where I struggled with your question -- why, oh why, are you trying to optimize something as trivial as this? I mean, it should be a one liner. I normally wrap stuff like this in a bash script and leave it alone:

#!/bin/bash perl -pi.bak -e 's{a}{b}g' $1

Epilogue

I have been messing around with Javascript so much that I started thinking about ways to make asynchronous calls after copying a file to my folder. Perhaps I would use this Future module...

Celebrate Intellectual Diversity


In reply to Re: Avoid re-invocation for -pie processing by InfiniteSilence
in thread Avoid re-invocation for -pie processing by seismofish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.