in reply to Re: How to reference to array keys?
in thread How to reference to array keys?


Hey Marshall,

I copy/pasted in your code but from this line -->(line 20) if (m|^/|)... From that line on down it looks like you are missing a quotation mark or a backslash in the if.
Should it be more like this? Or something like this?
if (m|/^/|)

Thanks, Matt

Replies are listed 'Best First'.
Re^3: How to reference to array keys?
by Marshall (Canon) on Jul 27, 2011 at 19:26 UTC
    No, the code is fine like it is. What is happening is that I changed the default separator for the regex from '/' to '|'. When that happens, there has to be an explicit "m" in front of it. "if (/^\//)" would be the same effect. Since the '/' means regex starts/ends, I have to escape the '/' at the beginning of the line and we wind up with a bunch of "leaning toothpicks". The aesthetics these leaning toothpicks didn't look very good to me so I changed it. Sometimes you will see if (m{^/}) because another way is to use curly braces.

    Sounds like you have a text editor that is not so smart and its leading you astray with wrong highlighting.