use strict; my @manifest; my $recurse=0; for (@ARGV) { if (/^-M(.*)$/) { push @manifest, $1; } elsif (s/^-r$//) {$recurse=1} elsif (s/^-R$//) {$recurse=0} } my @files = (); sub getf { my ($p) = @_; my @res = (); opendir FDIR, $p; for (readdir FDIR) { next if /^\.*$/; if (-f "$p/$_") {push @res,"$p/$_"} elsif (-d "$p/$_") {push @res,getf("$p/$_")} } closedir FDIR; return @res; } if ($recurse) { my @f; for (@ARGV) { s/[\/\\]+$//; if (/^(.*?)[\\\/]([^\\\/]+)$/) { my ($path, $patt) = ($1,$2); push @f, getf($path); $patt =~ s/([.+])/\\$1/g; $patt =~ s/\?/./g; $patt =~ s/\*/(?:.*?)/g; push @files, grep {/[\/\\]$patt$/} @f; } elsif (-f) { push @files, $_; } } } else { push @files, @ARGV; } for (@manifest) { open FIN, "<$_"; push @files, grep {!/^#/ and !/^\s*$/} <FIN>; close FIN; } undef $/; sub retr { my $str = shift; for ($str) { s/(["\\])/\\$1/g; s/(\r?\n)/\\n\\$1/g; } return $str; } for (@files) { next unless -f; my $bb = 0; open FIN, "<$_"; binmode FIN; my $f = <FIN>; my $f0 = $f; close FIN; if ( $f=~s/^(#ifdef PERL_SOURCE((?:_S)?))(\r?\n)(.*?)#else(.*?)#endif/ ((index($4.$5,"#ifdef")>-1) or (index($4.$5,"#else")>-1)) ? $& : "$1$3$4#else${3}PERL_EVAL$2(\"\\$3".retr($4)."\");$3#endif" /megs ) { $bb = 1; } if ( $f=~s/^(#ifdef PERL_SOURCE((?:_S)?))(\r?\n)(.*?)#endif/ ((index($4,"#ifdef")>-1) or (index($4,"#else")>-1)) ? $& : "$1$3$4#else${3}PERL_EVAL$2(\"\\$3".retr($4)."\");$3#endif" /megs ) { $bb = 1; } if ($bb and $f0 ne $f) { print STDERR ">>>$_<<<\n"; open FOUT, ">$_"; binmode FOUT; print FOUT $f; close FOUT; } else { print STDERR " $_\n"; } }

In reply to RE: RE: To ease writing perl pieces from within C/C++ programs by vkonovalov
in thread To ease writing perl pieces from within C/C++ programs by vkonovalov

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.