Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: To Single Quote or to Double Quote

by jacques (Priest)
on Feb 01, 2005 at 21:15 UTC ( #427053=note: print w/replies, xml ) Need Help??

in reply to To Single Quote or to Double Quote

When it doesn't matter, I always use double unless I need single. When I am looking at thousands of lines of code, I prefer the obviousness of double quotes. Plus, eventually I might need to have the string interpolated, in which case I would have to change the quotes around if I use single.

Replies are listed 'Best First'.
Re^2: To Single Quote or to Double Quote
by Tanktalus (Canon) on Feb 01, 2005 at 21:18 UTC

    Funny - I do it exactly the opposite. I use singles unless I need double, because then interpolating happens only when I say so, and I otherwise don't have to pay attention to sigils or other special characters. When interpolation happens, then I have to scan the line to figure out if I want to go and escape everything, or if I leave it as-is, and use the concatentation operator '.'. As far as obviousness, I suggest a syntax-highlighting editor. ;-)

      I second your recommendation to use a syntax-highlighting editor, but I want to expand. Not all editors (even fte, sadly, which I loved) handle complex quoting in Perl in a sane manner. For example, an editor might have trouble with some of:

      qq[]; s///; y///; ##and so on, any with three separators s[][]; ##etc m,/,; ##non-standard matching, esp with a slash m/\//; #matching with an escaped version of a delimeter

      The only editor I've ever found that handles all of those correctly is SciTE.

      require General::Disclaimer;
      s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

        FYI - FTE handles all those just fine. It's not perfect, but those particular types are working currently. I've fixed many of the perl syntax highlighting problems in FTE, but I don't think any of those ever had a problem that I had to fix.

        My Windows editor of choice handles all of that just fine. I wish they made a Linux version.

        Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0
        perl -e 'print(map(chr,(0x4a,0x41,0x50,0x48,0xa)))'
      I also lean toward sticking with 's. For the "only interpolate when I really mean it" reason as well as my probably unfounded fear of a performance hit on "s.

Re^2: To Single Quote or to Double Quote
by Roy Johnson (Monsignor) on Feb 02, 2005 at 03:40 UTC
    You could use q"blah" instead of single quotes. You'd have the obviousness of double quotes, and if you needed to make it interpolate, you just remove the q.

    What could be more straightforward? ;-)

    Caution: Contents may have been coded under pressure.
      Remove the q? I prefer to use qq'blah' when I need interpolation. ;)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://427053]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2021-10-21 09:31 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (83 votes). Check out past polls.