by pfarnsworth · 10y ago · 0 comments
Again, this is my own personal opinion. I know many people have made some great software based on Perl, but it's the only language I won't touch with a 10 foot pole, and I've spent a couple of years programming in PHP and a year in COBOL.
|| has a higher precedence than or in Ruby as well.
> rubocop -D foo.rb
Inspecting 1 file
C
Offenses:
foo.rb:1:3: C: Style/AndOr: Use || instead of or.
a or b
^^
1 file inspected, 1 offense detected> who knows :|
> It Just Is.
> remember, perl is a memory competition
There is a LOT to remember about how Perl works.
1. PCRE copies the Perl regex syntax almost completely (except some much newer cases than \A and \Z). See e.g. http://www.rexegg.com/regex-quickstart.html for \A, \Z, \z
2. If you check http://perldoc.perl.org/perlre.html then:
\a alarm (bell)
\A Match only at beginning of string, as PCRE.
\z \Z Same as PCRE. (But \z is not in Regexps for Python/JS.)
Edit: You might want to note that the regexps are redone quite extensively in Perl 6 and to a large part replaced with grammar for those use cases.It _is_ a memory competition though. In the various languages I've learned, Perl feels like it has the most to remember about how things work or interact (ymmv of course, I'm speaking of my experience here).
Expressive is the good side of this. But you really need to have coding standards in place.
On this subject, to upgrade to Perl 6 will be a bit scary, like driving a much faster car. :-)
The ASCII table used to be the alpha and the omega. :-)
That is, it was not so much of unnecessary extra detail when the char codes was inserted into Reg exps. The newfangled Regexps and grammars of Perl 6 cleaned out a lot of lint.
You could probably make an argument for starting to remove, not only add, [more] features when you declare a perl version in a script.
(And personally, I only ever used \n, \r, \t and similar. Everything else is as Cthulhu meant it to be, octal. Regular expressions' problem always was readability, I never used more features than I need and /x is my friend. That said, the "modern" Perl 5 regular expressions are like grammars, really cool.)
I've seen some expensive boo-boos due to operator precedence mistakes (e.g. - in C)
That said, there are a lot of special variables that can be tedious to figure out (e.g. - $" vs $;), if somebody uses the less frequently used ones, rather than the long-form names.
Many years ago, I had a bookmark in my C manual (Harbinson Steele) for the operator precedence page.
After a while I removed that bookmark. I decided that if I needed to look at that list, I should use parentheses. :-)
man perlvar
was always pretty easy to search & explained the real purpose of whatever goofy line noise people would useI can remember $_, $? and $!, but that's about it. And I like Perl.
The rest were either just abandoned or given names such as $GROUP or $PROGRAM-NAME
$/ isn't the same as it was in Perl 5 instead it is for storing the result of successful matches. ( you can also assign to it )
$0, $1, $2 is short for $/[0], $/[1], $/[2] $<abc> is short for $/{'abc'} which can be spelled as $/<abc>
But ruby was a quite a happy move for me back then in 2006, language was underperforming, features were lacking, nowhere anything like CPAN, but I could express logic much closer to how I think about problems, without additional layer of "thought translation".
This one is useful. Remember that Perl was created for being a more powerful kind of shell.
Those operators have their precedence set so that you'll use || as a logical operation inside a command, and "or" for control flow between commands. The same is true for && and "and".