in reply to Quote and Quote-like Operators
FWIW, heredocs aren't ugly :) if text is more than one line, heredocs are my first choice, of the form
my $html = <<'__HTML__'; __HTML__ my $xml = <<'__XML__'; __XML__ my $foo = <<'__EOF__'; __EOF__
I've often pasted multiline text and had to adjust the delimiters, ditching '' and "" and {} for q~~. With heredocs this is very rare. I've had HERE or EOF show up a few times, but virtually never __EOF__, which I also like for its similarity to __DATA__ and __END__
Its part of my template, I even have a hotkey in my editor for heredocs
I also prefer qw' l i s t ' or qw/ l i s t/ because no shift key is involved, and its all pinky action (on QWERTY keyboard), use CGI 3.55 qw/ param /; use Data::Dump qw' dd ';
for oneliner portability, i prefer qq// and q//, much easier to move between shells , only have to change leading/trailing "" into '' and vice versa
For match/substitution, i prefer s/// and then to avoid leaning toothpick syndrome i switch to one of s;;; s=== depending on the regex, similarly because shift isn't required, and its all pinky action :)
for larger regex I always use balanced s{}{}ex; or
s{ }{ }ex;
though the options are ridiculous :D
perl -MO=Deparse -e " s///g " perl -MO=Deparse -e " s\\\g " perl -MO=Deparse -e " s[][]g " perl -MO=Deparse -e " s()()g " perl -MO=Deparse -e " s{}{}g " perl -MO=Deparse -e " s!!!g " perl -MO=Deparse -e " s###g " perl -MO=Deparse -e " s vvvg " perl -MO=Deparse -e " s ___g " perl -MO=Deparse -e " s {}//g " perl -MO=Deparse -e " s {}\\g " perl -MO=Deparse -e " s {}vvg " perl -MO=Deparse -e " s {}()g " perl -MO=Deparse -e " s {}[]g " perl -MO=Deparse -e " s {}<>g " perl -MO=Deparse -e " s<><>g "
you're correct, you definitely want to avoid alphanumeric for delimiters, esp fancy unicode
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Quote and Quote-like Operators
by jmcnamara (Monsignor) on Dec 15, 2011 at 17:31 UTC | |
by choroba (Cardinal) on Dec 16, 2011 at 00:38 UTC | |
by jmcnamara (Monsignor) on Dec 16, 2011 at 10:26 UTC | |
by tchrist (Pilgrim) on Dec 16, 2011 at 14:14 UTC | |
by tye (Sage) on Dec 16, 2011 at 16:26 UTC | |
|