[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] using DATA for testing



Folks,

I enter test data after the __END__ tag at script end and use it to test.
Here's a quick sample script:

#!perl
while (<DATA>) {
	print;
	print "\n** End of one loop. **\n\n";
}
__END__

I was wondering if there was any way to map one file handle onto another
for testing. For example, I have a script with 'while (<INPUT>)' where
INPUT is the result of 'open INPUT, $inputfile;' I then have a couple of 
spots where the script returns to the file top, etc. It would be handy to
change one line mapping INPUT to DATA during testing, rather than
switching every instance of INPUT to DATA.  I did see a remapping of
STDERR to STDOUT that gave me the idea (a CGI test technique):

	BEGIN {
		print "Content-type: text/plain\n\n";
		open STDERR,'>&STDOUT';
	}

Any suggestions?

Paul


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org