In article <[EMAIL PROTECTED]>, "Nicholas Clark"
<[EMAIL PROTECTED]> wrote:
> I hope this patch works. The one without MANIFEST did.
Here's a patch to the patch that ties a filehandle and removes the spawning. I
had to tweak one little regex and add a chomp to get things to work.
p5p's trimmed from this followup. Saying "REPATCH" seems a little rude.
That's an impressive test: AutoSplit is scary.
-- c
--- lib/~AutoSplit.t Mon Sep 24 21:05:59 2001
+++ lib/AutoSplit.t Mon Sep 24 21:05:01 2001
@@ -4,19 +4,16 @@
# work.
my $incdir;
-my $lib = '"-I../lib"'; # ok on unix, nt, The extra \" are for VMS
BEGIN {
chdir 't' if -d 't';
if ($^O eq 'MacOS') {
$incdir = ":auto-$$";
- $lib = '-x -I::lib:'; # -x overcomes MPW $Config{startperl} anomaly
} else {
$incdir = "auto-$$";
}
@INC = $incdir;
push @INC, '../lib';
}
-my $runperl = "$^X $lib";
use warnings;
use strict;
@@ -24,8 +21,7 @@
use File::Spec;
use File::Find;
-require AutoSplit; # Run time. Check it compiles.
-ok (1, "AutoSplit loaded");
+require_ok('AutoSplit');
END {
use File::Path;
@@ -45,6 +41,7 @@
close DATA;
}
+my $out = tie *OUT, 'TieOut';
sub split_a_file {
my $contents = shift;
my $file = $_[0];
@@ -54,15 +51,10 @@
close FILE or die "Can't close $file: $!";
}
- # Assumption: no characters in arguments need escaping from the shell or perl
- my $com = qq($runperl -e "use AutoSplit; autosplit (qw(@_))");
- print "# $com\n";
- # There may be a way to capture STDOUT without spawning a child process, but
- # it's probably worthwhile spawning, as it ensures that nothing in AutoSplit
- # can load functions from split modules into this perl.
- my $output = `$com`;
- warn "Exit status $? from running: >>$com<<" if $?;
- return $output;
+ my $orig = select(OUT);
+ AutoSplit::autosplit(@_);
+ select($orig);
+ return $out->read();
}
my $i = 0;
@@ -79,10 +71,10 @@
| \#(?!\#) # or a # character not followed by #
| (?<!\n)\# # or a # character not preceded by \n
)*)/sgmx;
- foreach ($args{Name}, $args{Require}) {
+ foreach (@args{qw( Name Require Extra )}) {
chomp $_ if defined $_;
}
- my @extra_args = !defined $args{Extra} ? () : split /,/, $args{Extra};
+ my @extra_args = !defined $args{Extra} ? () : split /,\s*/, $args{Extra};
my ($output, $body);
if ($args{File}) {
$body ="package $module;\n" . $args{File};
@@ -152,6 +144,30 @@
mkdir $dir, 0775;
}
}
+
+package TieOut;
+
+sub TIEHANDLE {
+ bless( \(my $scalar), $_[0] );
+}
+
+sub PRINT {
+ my $self = shift;
+ $$self .= join('', @_);
+}
+
+sub PRINTF {
+ my $self = shift;
+ my $format = shift;
+ $$self .= sprintf($format, @_);
+}
+
+sub read {
+ my $self = shift;
+ substr($$self, 0, length($$self), '');
+}
+
+package main;
__DATA__
## Name