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
|
| [reply] |
|
| [reply] |
|
Why not a <<@when doc@, then?
-----------------------
You are what you think.
| [reply] |
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__}. | [reply] [d/l] |
|
| [reply] |
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}
), $/;
| [reply] [d/l] [select] |
|
| [reply] |
|
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'?
| [reply] [d/l] [select] |
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." | [reply] [d/l] |
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? | [reply] |
|
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.
| [reply] |
|
| [reply] |
|
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.
| [reply] |
|
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
| [reply] |
|
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.
| [reply] |
|
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
| [reply] |
|
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.
| [reply] |
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
| [reply] [d/l] |
|
| [reply] |
Re: The most annoying common way to get a string literal in Perl is...
by ChuckularOne (Prior) 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. | [reply] |
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
| [reply] |
|
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..) | [reply] [d/l] |
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.
| [reply] |
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. | [reply] |
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". | [reply] |
Re: The most annoying common way to get a string literal in Perl is...
by beppu (Hermit) 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?)
| [reply] |
|
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).
| [reply] |
|
| [reply] |
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... | [reply] |
|
if($anything){
print <<" Ende" # =~s/ \n/\n/g #could be appended
Text
Ende
}
| [reply] [d/l] |
|
Sorry, sleep deprivation. The regex must be m" (.*?)$"msg;.
| [reply] [d/l] |
|