in reply to perl index function error when "use PDL"

It seems that the problem is that you're implicitly loading PDL::index here instead the perl function index. Don't load the PDL::index unless you think that you will need it
#!/usr/bin/perl -w use strict; use PDL::Core; use PDL::Index; use PDL::Basic; use PDL::Math; use PDL::Primitive; use PDL::Slices qw/!index/; # <-HERE is the problem (and the solution) use PDL::IO::FITS; my $test = "This is a test and I hope it works."; my $pos4 = index $test,"test"; print "pos4 = $pos4\n"; exit(0); __END__ pos4 = 10

Updated: In fact it was a little more complicated, really PDL::Index was not the culprit at the end, they are three different index here:

the perl function index a PDL function index in the module PDL::Slices (the real culprit) and a module named PDL::Index

Replies are listed 'Best First'.
Re^2: perl index function error when "use PDL"
by syphilis (Archbishop) on Oct 28, 2011 at 01:34 UTC
    Yes, it's the index function being exported by PDL::Slices that causes the problem.
    Why does perl fail to warn that index has been re-defined ?

    Cheers,
    Rob
      Why does perl fail to warn that index has been re-defined ?

      Because its not illegal to redefine built-ins. Just silly unless they perform the same function.

      C:\test>perl -Mstrict -wE"sub map{ 1 }"

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Because its not illegal to redefine built-ins. Just silly unless they perform the same function.

        I thought the whole idea of warnings was to let us know when we're doing something that's legal, but might have undesirable consequences ... eg, using an uninitialised scalar, or re-defining a built-in.

        (Yet another addition to my list of "Things I Was Wrong About" :-)

        Cheers,
        Rob