Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

First, the one-liner itself (shown with arbitrary example arguments and -t switch set), followed by the script file p-in-p.p (I follow a naming convention of making Perl application -- executable -- scripts with names *.p, library code in files named *.pl).

Also, please save the file p-in-p.p (or whatever you want to name it) to a reasonable location on your HD and then edit the one-liner below so the system can find it there (fully qualified path specification).

perl -"MFile::Dosglob" -e "sub NX{return shift @ARGV;};$P=quotemeta NX;$S=NX;$gb=NX; $opt_t=($t=NX)?$t:undef; push @ARGV,glob(qq{*.$gb}); @O=@Y=@ARGV; for(@O){ $T{$_}=(stat $_)[9]; print qq{\n},$_,q' ',($lt=localtime($T{$_})),qq{\n} ;} if (! $opt_d){for (@O){splice @O,$n++,1,q{\"}. $_ .q{\"};} open(TF,qq{>TMP.~});print TF join qq{\n},@O,$S,$P;close (TF); ($ev=scalar eval qx{TYPE e:\\scr\\p-in-p.p}) or warn $@; if ($opt_t){ for(@Y){ print STDERR qq{\n$_ ! };$r+=utime(time,$T{$_},$_); }; print qq{\n\n Filetimes restored for $r files out of $ev files.\n\n};}}" "i" "I" "txt" -t

The script file:

#!perl #p-in-p.p open LOG, ">LOG.~" or die $!; @ARGV = split /\n/,`TYPE .\\TMP.~`; print LOG "Patterns: ",qq{\n} x 2, join qq{\n}, @ARGV[$#ARGV,$#ARGV-1] +,qq{\n}; $P=pop @ARGV; $S=pop @ARGV; @ARGV = sort {uc($a) cmp uc($b)} @ARGV; print LOG "\n" . @ARGV . " Files: ",qq{\n} x 2, join qq{\n},@ARGV, qq{ +\n}; @ARGV = &Dequote(@ARGV); my $countfiles = $#ARGV + 1; $^I=q{.PBU}; $S =~ s#\\@#@#g; while (<>){ my $former = $_; chomp $former; if (s/($P)/$S/g){ print LOG qq{\n},q{ Now in file: }, $ARGV , qq{:\n}; print LOG qq{Replacing: *${1}* in: } .'"' . $former . '"' .qq{ +\n}. qq{with: } .'"'. $_ .'"'. qq{\n}; print; } print; }; close (LOG); system "notepad LOG.~"; sleep 3; unlink qw{LOG.~ TMP.~}; return $countfiles; sub Dequote { for (@_) { $_ = substr ($_,1,(length $_) - 2); } return @_; }

In reply to In-Place editing system by Intrepid

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (8)
    As of 2020-07-03 14:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?