Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

The most annoying common way to get a string literal in Perl is...

by tye  (Monk)
on Jun 16, 2004 at 15:42 UTC ( #367278=poll: print w/ replies, xml ) Need Help??

vote on The most annoying common way to get a string literal in Perl is...

'singles'
[bar] 48/7%
"doubles"
[bar] 51/8%
q(mixed singles)
[bar] 13/2%
qq<mixed doubles>
[bar] 29/4%
q/unmixed singles/
[bar] 24/4%
qq!unmixed doubles!
[bar] 44/7%
qw(wordly)
[bar] 47/7%
bareword
[bar] 194/29%
<<"here doc"
[bar] 95/14%
<<'there doc'
[bar] 39/6%
__END__
[bar] 92/14%
676 total votes
Comment on The most annoying common way to get a string literal in Perl is...
Re: The most annoying common way to get a string literal in Perl is...
by gri6507 (Deacon) on Jun 16, 2004 at 17:22 UTC
    is it just me, or does everyone else's editor make it real hard to distinguish ' from " (and also `)? Which font makes it easy?
      It depends more on the font you use. The X fonts made the backtick more vertical than it should be. The apostrophe (single quote) was also slightly angled. This led to the backtick and apostrophe being used as way of faking smart quotes.

      With newer fonts, the backtick is more angled and easier to distinguish. Try switching the font on your editor or terminal window to something else. Any of the scalable (TrueType) fonts would do it.

        Or most any font at 14 or 18 pt. :) I myself actually tend to use Courier New, I hate trying to code with a variable-width font!

        - - arden.

      Use a monospace font, they're better for important text things like ascii-art and coding anyways. I prefer Lucida Console

      --
      I'm not belgian but I play one on TV.

      Which font makes it easy?

      I'm quite fond of Vera Sans Mono and I like Andale Mono. Both are nice sans serif fixed-width fonts, much nicer than Courier.

      Vera Sans looks gorgeous, except that maybe the minus glyph is slightly too discrete.

      And I'm not mad about the zero glyph in Andale. It has a horizontal bar running through it, to make it easy to distinguish it from the uppercase O glyph. I bar my zeros when I put pen to paper (when writing code longhand) but I find it annoying in a screen font). But the parens and curlies are very easy to distinguish, choose your poison.

      But both are definite improvements on Courier and Lucida Console.

      - another intruder with the mooring of the heat of the Perl

      My favorite font that makes these very distinct (as well as many other characters that can be a pain to distinguish) is ProFont. Vera Sans (mentioned above) is nice too, though it doesn't looks as nice as it scales down.

      I was a lucida console fan for a long time, but my favorite has become neep. It looks very nice both small and large. I run it at 14 point (-*-neep alt-medium-r-normal-*-14-*-*-*-c-*-iso8859-1 ) at 1600x1280 and it looks great. No trouble with ", ', or ` either.

      --
      Diplomacy is the art of saying "Nice doggie" until you can find a rock.
      naChoZ

      I do all of my coding on a Unix console, which doesn't suffer from those things. If $^O eq "Win32", you can get console versions of Unix editors.
Re: The most annoying common way to get a string literal in Perl is...
by ambrus (Abbot) on Jun 16, 2004 at 18:07 UTC
    The most annoying is actually do{package whatever; __PACKAGE__}.

      It did specify common way.

      ----
      send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.

Re: The most annoying common way to get a string literal in Perl is...
by ChuckularOne (Parson) on Jun 16, 2004 at 19:28 UTC
    I have never used most of these! So I opted for the most annoying one I HAVE used.
Re: The most annoying common way to get a string literal in Perl is...
by rir (Vicar) on Jun 16, 2004 at 21:16 UTC
    "Hi, ".$obj.'at' .$loca. ', and  '. $pron, ", we'd" ." like you to use","'".'s',", please."
Re: The most annoy.....
by Paulster2 (Priest) on Jun 16, 2004 at 21:27 UTC

    Mixed doubles, because the backswing can be murder...DUCK!

    ps: Why didn't someone tell me that there was a common way to get a string literal!

    Paulster2


    You're so sly, but so am I. - Quote from the movie Manhunter.
Re: The most annoying common way to get a string literal in Perl is...
by saskaqueer (Friar) on Jun 16, 2004 at 23:44 UTC

    I'm surprised that bareword came up as most unpopular. I know for a fact that there are a million and two Perl programmers that use unquoted strings when it comes to hashes and lists. This makes me wonder if perhaps using => as a comma operator and unquoted hash keys are not generally considered barewords. Example follows of course.

    #!perl -w use strict; my %en2fr = ( one => 'un', two => 'deux', three => 'trois' ); # yes I realize there are better ways to grab the # hash values, this is for demonstration only :) print join( ', ', $en2fr{one}, $en2fr{two}, $en2fr{three} ), $/;
      I thought of this as well, before I voted for bareword. And I thought some more. And I arrived at the conclusion that bare words that are not ambiguous in their context are not bare at all -- in fact, they bear it quite well.

      There you have it. The Emperor has Clothes.

      Cheers!
      Matt

      Don't make me groan and bare it.

      I voted for bareword too. But I don't consider one => 'un' as being bareword as => explicitly (AFAIK) defines the word to it's left as being quoted.

      OTOH I render $en2fr{one} as being use of a bareword which I absolutely dislike. Consider this example and tell me without testing it's output:
      $umask= umask; $hash{$umask}='umask value'; $hash{'umask'}='umask text'; print $hash{umask};
      • Is the output 'umask text'?
        How can you make sure it will be 'umask value'?
      • Or is the output 'umask value'?
        How can you make sure it will be 'umask text'?
Re: The most annoying common way to get a string literal in Perl is...
by tune (Curate) on Jun 17, 2004 at 07:04 UTC
    What about
    my $text = qq~Hello hehe.~;
    ? It makes me shiver.

    --
    tune

      That would fall under the category of 'unmixed doubles' :)

Re: The most annoying common way to get a string literal in Perl is...
by tbone1 (Monsignor) on Jun 17, 2004 at 14:11 UTC
    Hm, looking through the choices, I am now seized with a desire to create a <<`where doc`.

    And maybe a <<?whatsup doc?

    --
    tbone1, YAPS (Yet Another Perl Schlub)
    And remember, if he succeeds, so what.
    - Chick McGee

      That sounds like a "carret and schtick" situation to me.

      sorry for the bad joke, I just can't help it

      Why not a <<@when doc@, then?


      -----------------------
      You are what you think.

Re: The most annoying common way to get a string literal in Perl is...
by rinceWind (Monsignor) on Jun 21, 2004 at 11:00 UTC
    Mixed singles, Mixed doubles...

    Oh, it's the time of year again for Wimbledon :).

    On a serious note, what gets me are long string literals that wrap 80 columns, and string literals that contain newlines rather than "\n". The long strings should be broken down using concatenation with '.', and multi line strings should use here docs or "\n".

    --
    I'm Not Just Another Perl Hacker

      Eh, Why? Whats wrong with:
      my $var = " stuff stuff more stuff yet more stuff? amazing stuf";
      ?

      ( Granted I probably just prefer that because my brain dead editor can't highlight here-docs..)
Re: The most annoying common way to get a string literal in Perl is...
by tilly (Archbishop) on Jun 27, 2004 at 00:26 UTC
    Apparently a lot of us aren't fans of the poetry optimization. I'll leave speculation about what that implies about our personalities to others.
Re: The most annoying common way to get a string literal in Perl is...
by Anonymous Monk on Jun 27, 2004 at 11:59 UTC
    I voted for doubles, but of course only in the case where they are superfluous as in "nothing interpolated" or "$variable".
Re: The most annoying common way to get a string literal in Perl is...
by december (Pilgrim) on Jul 02, 2004 at 17:07 UTC
    Definitely here-documents and especially __END__. It screws up the whole indenting, and makes me loose my oversight and position in the code. They'd be great if the indenting problem could be fixed somehow, though...
      It can. Did you try:
      if($anything){ print <<" Ende" # =~s/ \n/\n/g #could be appended Text Ende }
        Sorry, sleep deprivation. The regex must be m"    (.*?)$"msg;.
Re: The most annoying common way to get a string literal in Perl is...
by beppu (Friar) on Jul 05, 2004 at 13:28 UTC
    I don't get the difference between "here doc" and 'there doc' except that one uses double quotes for the terminator and the other uses single quotes. (Is that the only difference or is there something more subtle to be aware of?)

      Both examples are really "here" docs. The poll author was just being silly.

      ----
      send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.

      Same as the difference between 'single' and "double": one interprets and one doesn't. Though <<'there docs' are unique in Perl for never treating \ as anything other than just \.

      If you thought "there doc" was some official term, then perhaps you didn't notice that most of the names used aren't names you'll find often used (never in the standard docs, for example).

      - tye        

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-09-18 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (110 votes), past polls