Hi, This is somewhat basic so I apologise if this has been answered somewhere, but I had difficulty in finding the solution using some simple searches. Regardless, my problem is that I'm having a conflict in using 'PDL::index' and Perl's 'index'. Basically I have a script that is using predominantly PDL coding but I'd like to take advantage of Perl's index function, something like this:

 use PDL; ... (a bunch of PDL lines of code) ...; $tmpsub = substr( $perlstr , index( $perlstr , /myregex/ ) , $position );

The problem with the above line is that it attempts to use PDL::Index. I have tried to the following as a solution:

 use PDL; ... (a bunch of PDL lines of code) ...; $tmpsub = substr( $perlstr , $main::index( $perlstr , /myregex/ ) , $position );

But this fails because of my lack of understanding. Basically I would like to use Perl's main 'index' function in the above line and not PDL's 'index'. Hopefully this is a straightforward solution, and that I will not receive too much bludgeoning for having asked such a trivial question. Kind Regards, Dan


In reply to perlfunc index name conflict by dpath2o

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.