UPDATE: else: is a label. my bad.

So I'm learning Python. I always disdained it because no curlies, but once you start doing stuff in it you get used to it. Sort of

But I still use Perl when I want to cobble something up quick. Using multiple languages has it's issues, though. I get confused. Here's one case where Perl seems to be confused, too, at 5.26.1. I installed perlbrew and it still happens at 5.032000 and 5.033001

#!/usr/bin/perl print "Perl version is: $]\n"; use strict; use warnings; if ( 1 ) { warn "there can only be one, and it's in the IF clause\n" } else: # beware that colon!!!! that's Python, not Perl!!! { warn "there can only be one, and it's in the ELSE clause\n" }

produces

Perl version is: 5.026001 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause Perl version is: 5.032000 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause Perl version is: 5.033001 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause

No warnings, no syntax errors, nothing except the (seemingly) impossible behavior

Removing the colon from the else statement restores correct behavior. gvim didn't catch it either - it's syntax highlighting is as if this was perfectly valid.

Is this a bug, or am i being persnickety?

--Bob

All code given here is UNTESTED unless otherwise stated.


In reply to Python gave me a colonic (solved - brainfart) by bobn

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.