in reply to perl index function error when "use PDL"
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
|
|---|