It scans all files in current folder and with a specified extensions and changes anything between #ifdef PERL_SOURCE and #endif into a construct that C compiler will correctly understand as a string which may be fed to a perl-calling function.
<CODE>
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*$%2
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.