Well, I've never made my own module before, so now you've just got me guessing. But if your module is called Foo, then does 'rcols *Foo::DATA' work? I'm just going on a statement in my book here that says "The __DATA__ token opens the DATA handle in whichever package is in effect at the time, so different modules can each have their own DATA filehandle, since they (presumably) have different package names."

Derek

Matthew Kenworthy wrote:

Hi Derek,

(CCed to Robert, who provided the same solution)

Thanks for the solution - however, the method doesn't seem to work if
you put the subroutine into a separate .pdl module.

Example file is test_read.pdl:
=== START test_read.pdl ===
sub test_read {
   use PDL;
   use strict;
   ($a, $b) = rcols *DATA;
   print $a, $b;
   return (1);
}
1;

__DATA__
1 2
3 4
5 6
7 8
=== END ===

trying this method gives:

home$ perl -e 'use PDL; use PDL::AutoLoader; &test_read();'
File *main::DATA not found

Is there some way I can tell the .pdl module that there's a main::DATA
handle further down in the script?

Thanks,

Matt



_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to