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

Re: [MacPerl-AnyPerl] using DATA for testing



At 12:00 -0400 1999.08.11, Paul Corr wrote:
>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):

  *INPUT = *DATA;

The only problem with this is that it also maps @INPUT to @DATA, %INPUT to
%DATA, etc.  This is better:

  *INPUT = *DATA{GLOB};

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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