Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Do you really need a deferred pattern there? I’d write it like so:

    qr/(?:$QUOTED|$NUM)(?(?{ '.' eq $+ })$FAIL)/;

    (which of course implies variables rather than constants.)

    Now given that, you get a zero-length match:

    $VAR1 = [
              'name => ',
              '"foo"',
              ', fav',
              '',
              '.num => ',
              '3'
            ];

    So obviously a match against the lone dot was prevented, but $QUOTED succeeds in matching nothing.

    Okay then.

    qr/($QUOTED|$NUM)(?(?{ '.' eq $+ or not length( $+ ) })$FAIL)/;

    Result:

    $VAR1 = [
              'name => ',
              '"foo"',
              ', fav.num => ',
              '3'
            ];

    Well, I never. That’s what we wanted!