1nickt has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I see a couple of the brethren use code style like this:

my %foo = @bar; ;; my $baz = qux();
What is the purpose of the lines with only two semi-colons? As far as I could learn from the internets this is a very specific-use C construct. Why is it in Perl code? Is this just a way to maintain spacing between "paragraphs" in the face of perltidy or some other utility that strips blank lines? If so, why not just use a pound sign?

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re: What Is the Purpose of a Line with only Two Semi-Colons?
by davido (Cardinal) on Aug 22, 2015 at 20:44 UTC

    I think it's an artefact from the REPL that some folks around here use for one-off testing.


    Dave

Re: What Is the Purpose of a Line with only Two Semi-Colons?
by LanX (Saint) on Aug 22, 2015 at 19:18 UTC
    I've never seen this as an intentional construct in Perl

    Do you have a link?

    There is a convention for single, double and triple semicolons in LISP, but there it's a comment symbol.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      I'm wondering if this is code that used ;; as a code placeholder, prior to v5.12.0's ellipsis.

        That's a nice idea and thanks, I wasn't aware that the ellipsis already came with 5.12.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

      Sure. The most recent example is here.

      The way forward always starts with a minimal test.

        I'm the one who posted the example here, and I can confirm that in that case at least, davido's guess below (update: and LanX's above) is quite right: it's a personal formatting convention associated with the REPL I wrote for myself, which collapses all blank lines to nothing. I've seen double-semicolons used in code examples from BrowserUk, but in that case I think it has some actual, functional use in his personal REPL.


        Give a man a fish:  <%-{-{-{-<

        I can only guess it might be a workaround to separate larger chunks in windows command line.

        But why don't you ask there? :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

      Agree, I double the semicolons normally in lisp and often the # in perl. Just in case I delete one of them by mistake.

      It seems that this is not an obvious error in perl in any case, bad style maybe, but no harm

      perl -Mdiagnostics -Mstrict -Mwarnings -e 'print "ok\n";;;;;;' ok
        > I double the semicolons normally in lisp

        In LISP it's more than just personal taste

        see Comments tips

        but could be that it's mainly an emacs thing.

        update
        Apparently a convention for all dialects, not only emacs

        LISP commenting convention

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Re: What Is the Purpose of a Line with only Two Semi-Colons?
by LanX (Saint) on Aug 24, 2015 at 03:10 UTC
    > If so, why not just use a pound sign?

      £?

    Took me a while to find out that # is called the pound sign in NA... :)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      LOL. I didn't want to say 'hash' because seemed prone to misinterpretation. 'She' from 'shebang'? Nah, worse! (time passes ...) Ooh! "Octothorn" -- I like that!

      William Sherk in 500 Years of New Words (1983), p. 272, has the follow +ing entry: "Octothorn, The number sign (#); so called because there are eight poi +nts, or thorns, sticking out of it ..."
      cit. Yahoo Answers

      The way forward always starts with a minimal test.