Can a function in a module read the __DATA__ of the calling program?
I have a module which contains a function that reads a filehandle, $fh.
I'd like to write a test which tests that function. To do that, I need to provide it some sample data. I figured I would just drop a few lines into the __DATA__ section of the testing program, then point $fh at the *DATA handle and test away.
Unfortunately, it doesn't seem to work.
Here's what I'm trying (more or less):
In test.pl:
$fh = *DATA; my $results = $app->process(); is ( $results->{item1}, "result1", "process item1" ); __DATA__ item1,data1 item2,data2 item3,data3
In Module.pm:
use vars qw($fh); sub process { my ($self) = @_; my $reslts = {}; while (<$fh>) { [do stuff] $results->{$key} = $result; } return $results; }
What basic bit of idiocy am I committing this time? :-)
Wally Hartshorn
In reply to Problem Reading __DATA__ in a Module by Wally Hartshorn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |