Hi, not to hijack your thread, but I just ran into a similar glitch with PDL's overriding core subroutines.

It all involved the claim, that what you entered in the PDL shell, perldl, would also run as a Perl shell script. So I took some code from the Newbook tutorial, ran it fine in perldl, then copy&pasted it to a Perl shell script. I got this weird error:

" syntax error at ./z line 18, near "$gal("
Global symbol "$section" requires explicit package name at ./z line 19, <DATA> line 387.
Execution of ./z aborted due to compilation errors."
the code is this
#!/usr/bin/perl use warnings; use strict; use PDL; use PDL::Graphics::PGPLOT; my $a = rfits "m51_raw.fits"; my $flat = rfits "m51_flatfield.fits"; imag $flat; <>; my $gal = $a / $flat; # !!!!!!!!! this is line 18 !!!!!!!!!!!!!!!!!!!!!! my $section = $gal(337:357, 178:198 ); imag $section; # It's the bright star <>; __END__

It's an overriden function, and I forgot perldl says in it's statrup text that PDL::NiceSlice; is autoloaded with Readline, and are overriden. Giving no error other than a syntax error.

Interestingly, in the module source dir, PDL/utils is a script named perldlpp.pl, whose job it is to filter out the NiceSlice overrides, and change it to legal core Perl. After running my script thu this filter, line 18 changes like this, and the script runs fine without using "use PDL::NiceSlice;"

# pre:filter line 18 is this: # my $section = $gal(337:357, 178:198 ); # imag $section; # It's the bright star # post filter line 18 is this, and runs without "use PDL::Nice::Slice" my $section = $gal->nslice([337,357,1],[178,198,1]); imag $section; # It's the bright star

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: perl index function error when "use PDL" by zentara
in thread perl index function error when "use PDL" by allori

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.