in reply to Re: Re: numbered sourcecode listing (oneliners)
in thread numbered sourcecode listing (oneliners)

You can omit the caret in that one too.
Only if I was golfing and not worried about being clear and working in all circumstances. I never trust the empty match, since it depends on the most recent successful match. True, here, it defaults to an empty string, but why count on that when one single character fixes that problem and communicates the proper intent?

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Re: Re: numbered sourcecode listing (oneliners)

Replies are listed 'Best First'.
Re: Re: Re: Re: numbered sourcecode listing (oneliners)
by Anonymous Monk on Aug 30, 2001 at 11:43 UTC
    In Perl "// == /$&/". Is it unintentional or useful feature? I can't imagine any situation when this feature is helpful.
Re: Re: Re: Re: numbered sourcecode listing (oneliners)
by PetaMem (Priest) on Jul 30, 2001 at 18:09 UTC
    Because you were in the midst of a golfing match.
      Because you were in the midst of a golfing match.
      No, I wasn't. Read the thread carefully. I responded for my simple mechanism in response to a snippets posting. Part of that posting suggested that some of the original ideas might be good golfing, but that's not where I went with it.

      So, if not golfing, then practice safe regex. {grin}

      -- Randal L. Schwartz, Perl hacker