include processed by a C preprocessor : no syntax analysis is done
Aha, I see where you're coming from now. Unfortunately perl really isn't geared towards source manipulation in that way - all its including functions must evaluate the code in the given file before including it into the parent source, such is the nature of perl. This behaviour is due to the fact that perl is a semi-interpreted dynamic language (it's compiled down to internal bytecode and then executed within
perl) so when you
require a file it is performed at runtime and therefore
must be syntactically sound and pass any strictures that might be in place. As for
use that's just a
require done at compile-time and also calls the import method of the given package.
So, finally, to answer your question (as I now understand it ;), no, perl has no 'simple 'include'.
But here's one I made earlier (as it were)
package include;
use IO::File;
use Regexp::Common 'quoted';
use Filter::Simple;
=head1 SYNPOSIS
use include;
include Foo::Bar;
include "somefile.pl";
=cut
FILTER_ONLY
code => sub {
local $/;
s< ^ \s* include \s+ (.*?) ; $>
( my $f = $1;
if($f =~ /^['"]) {
(undef, undef, $f) =
$f =~ $RE{quoted}{-keep};
} else {
($f = "$f.pm") =~ s<::>(/)g;
}
my $fh = IO::File->new($f) or die("include: $!");
$fh->getlines
)xg;
}
;
Roughly, the code should act like
#include does in
C by just dropping the source of the given package or file in place. It's untested at the moment, but hopefully it should DTR. There's also
Text::MacroScript but I'm not sure if that meets your needs of a 'simple include' (although my gruesome filter is hardly simple ;).
HTH
_________
broquaint