Consider:
#!/usr/bin/perl -w # # use strict; my $string = 'no semi-colon'; print $string,"\n";
vs
#!/usr/bin/perl -w ;# ;# use strict; my $string = 'semi-colon'; print $string,"\n";

I don't see how the second version with the semi-colon (;) preceding the pound (#) has any significant overall effect on the code below it. A few monks have queried me about this 'weird' syntax, but I still remain nescient of what the big deal is.

-tengo mas que aprender

Replies are listed 'Best First'.
Re: Comments in my code
by busunsl (Vicar) on Nov 09, 2001 at 15:16 UTC
    I consider everything that is useless in a source as bad.

    You see it and you think about it and then find out it shouldn't be there in the first place. This is waste of brain cycles!

    Making blank lines a comment is useles, leave them empty if you want to have them.
    Of course you will want to have them to make the code readable.

    Putting a semicolon in front of a hash sign followed by nothing is even more useless (if that's possible).

    Just my DM 0.02

Re: Comments in my code
by Fletch (Bishop) on Nov 09, 2001 at 18:18 UTC

    If you want something more visually distinct from the shebang, consider using multiple octothorpes</pedantic>. I like using 2 for block comments, and one for trailing.

    #!/usr/bin/perl ## ## foo -- Program for doing foo ## ## $Id$ ## use strict; ## ## Required modules ## use POE qw( Session Wheel::Run ); use LWP::UserAgent (); ## ## Explain what we're looping over, yadda yadda yadda ## blah blah yackety schmakety ## foreach( @something ) { push @somethingelse, $fooble; # push fooble on other list }
Re: Comments in my code
by maverick (Curate) on Nov 09, 2001 at 18:35 UTC
    Another thing that will be helpful to you (along with the other's suggestions), is to use an editor that supports syntax hilighting. There are several different ones for several different platforms. Running a Super Search on the monastery will give you several conversations on the matter of perl friendly editors. I personally run 'gvim' on Linux, and have my comments set to a medium grey color. The are still completely readable, but unobtrusive in the code.

    HTH

    /\/\averick
    perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

      Here is an example of gvim's syntax highlighting capabilities for the curious:

      #!/usr/bin/perl -w
      #####################################################
      # Script:   mp3_average_year
      # Author:   Jeff Anderson
      # Date:     03/15/2001
      # Comments: finds average year of my mp3 collection
      #####################################################
      
      use strict;
      use File::Find;
      use MP3::Info;
      
      my ($sum,$count);
      my $start = shift || '/mnt/lump/mp3';
      
      find sub {
          if (/mp3$/) {
              my $tag  = get_mp3tag($_);
              my $year = $tag->{'YEAR'};
              next unless $year =~ /^\d+$/;
              next unless ($year > 1950 and $year < 2002);
              $sum += $year;
              $count++;
          }
      }, $start;
      
      print "$sum / $count = " . $sum / $count . "\n";
      

      UPDATE:
      Oh yeah, _PLEASE_ don't actually do what i just did and actually post gvim rendered HTML, as the resulting HTML increases in size tenfold. Guess that makes me a hypnotist.

      jeffa

      i liked it better than cats, i will use gvim again and again ...

        <rant>

        Looking at that reminds me why I hate syntax-colouring editors. And I am indebted to stefp for jogging my memory, by talking about angry fruit salad (on the Paris Perl Mongers list -- this subject came up the other day).

        I know, I know, the colours can be configured, but I still why wonder why a person with a knowledge of psycho-optics and some decent design skills hasn't come up with a default that's useable in the first place. Edward Tufte springs to mind.

        I finally managed to wean my self off Notepad, and use vim in Windows... after having figured out how to turn syntax coloring... off.

        </rant>
        --
        g r i n d e r
        Oh yeah, _PLEASE_ don't actually do what i just did and actually post gvim rendered HTML, as the resulting HTML increases in size tenfold. Guess that makes me a hypnotist.

        Oh, yes do it.You can't cut text in a gif save using OCR and I wonder which OCR software would be smart enough to deal with angry fruit salads :)
        By the way, how do you dump the html from vi?

        And sure enough, like said grinder below, Tufte books are mandatory reading.

        -- stefp

Re: Comments in my code
by davorg (Chancellor) on Nov 09, 2001 at 15:22 UTC

    I agree with busunsl, both versions look pretty pointless to me. Perhaps you could tell us why you would use them.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      I just did not put anything in the space after the comments.

      I just ocasionally use

      #!/usr/bin/perl -w ;# ;# usage: blah blah
      then I go on to use
      # comment without the ;
      simply for my own reasons: I like the way it looks at the beginning separate from the shebang.

      -tengo mas que aprender
        What are your reasons?

        Personally the first one that popped into my head on seeing the style was, "Sounds like someone who has done way too much Lisp." :-)

        There's nothing really brain damaged about your convention, but it is non-parsimonious. That's a big word for anything not on the straight line between two points. Non-parsimonious things tend to jump out and bother experienced programmers. When you're looking at any code and trying to understand it, you're constantly asking 'What does this do, and why does it do it?'.

        The truth is that if you stare at anything long enough it will start to look familiar, and that's good. It helps us code. But since your the only one doing it, it's not going to help anyone else. And since it's non-parsimonious it's actually going to bother us.