logo       

Re: Re: Using __DATA__ in a .pdl module: msg#00028

Subject: Re: Re: Using __DATA__ in a .pdl module
I think Matt has found a bug in PDL::AutoLoader and/or PDL::NiceSlice::perldlpp actually...... Yeah...

The code is it stands should work - and indeed _does_ work if you do a very simple:

 perldl> do 'test_read.pdl'
 perldl> test_read()

or, to use Matt's version:
perl -e 'use PDL; use PDL::AutoLoader; do "pdllib/test_read.pdl" ; test_read () ; '

which is essentially what PDL::AutoLoader (should) do.

I don't know where the bug is and don't really understand the interaction between Autoloader, 'do' and the data-handles so if anyone want to dig, do feel free.

As for a fix, I don't think there is anything except changes, either:

  a) Encapsulate the data with the function
or
b) Put the function definitions into a package and then use the full package reference for the DATA handle...


                                                Cheers,
                                                        J.


On 7 Mar 2007, at 17:19, Derek Lamb wrote:

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
Perldl@xxxxxxxxxxxxxxx
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe