4 ms·
I've used Perl extensively inside the BBC, Credit Suisse First Boston and a few other big corps. Also was a dev on a global warehouse management system written
by mmaunder 13y ago
I've used Perl extensively inside the BBC, Credit Suisse First Boston and a few other big corps. Also was a dev on a global warehouse management system written in Perl. But saying your startup is using Perl is not going to get you funded or laid anymore (and I miss grunge too) so there's not much love for it in Valley/Incubator circles.
These days I'll drop into coding in Perl for the regex syntax and backticks. But the reality is there's not much difference between it and PHP in terms of features. Used to be that it was better than Ruby because of performance and stability but they're about par now. So I don't think there's much point in evangelism or debate about Ruby vs Perl vs PHP or even Java anymore because they all get the job done in pretty much the same way. From a practical PoV I'm more interested in languages that actually do something well that other languages suck at e.g. node. I wrote a FSM/Long Polling web server implementation in Perl using epoll() before Node came along and now I love node more than most (and still wear the scars from a particularly tough hashref autovivification bug).
- eieio 13y ago> and still wear the scars from a particularly tough hashref autovivification bug As an infrequent perl programmer[1], I'm curious about the bug. Googling tells me that perl if($foo->{bar}) will always pass, which is pretty goofy to me. Was it something like that? [1] Well really, a bad perl programmer. I've occasional had to make minor edits to legacy perl. I don't write perl. And, as the mistake in this post shows, that's probably a good thing :)
- seeken 13y agoThat will not always pass. if (exists $foo->{bar}){ .. will not run .. } if ($foo->{bar}) {...} if (exists $foo->{bar}){ .. will run .. }
- eieio 13y agoI see, thank you. I am certainly a perl novice.
- pflanze 13y agoThat doesn't do any autovivification. You meant (note the referencing down a deeper level than the exists test): if (exists $foo->{bar}){ .. will not run .. } if ($foo->{bar}->{baz}) {...} if (exists $foo->{bar}){ .. will run .. }
- seeken 13y agoCan't believe I've had that wrong for so long. Must have misinterpreted it right when I learned perl and have always been careful about it.
- mmaunder 13y agoYes, you auto create variables in a hash when you reference then, so autovivification is just a fancy word meaning automatically declaring and setting a null value. So $myvar->{speling} would create that in a hashref silently. Creates horrible hard to find bugs.
- duskwuff 13y agoProbably worth noting that there is a Perl module which fixes this wart! no autovivification; http://search.cpan.org/~vpit/autovivification/lib/autovivification.pm http://search.cpan.org/~vpit/autovivification/lib/autovivifi... One of the things that's always impressed me the most about Perl is the degree to which modules can play with the language. Modules can add control structures (Try::Tiny), introduce new metaprogramming syntax (Moose), add operator overloading (overload)... it's very flexible.
- einhverfr 13y ago> One of the things that's always impressed me the most about Perl is the degree to which modules can play with the language. That's exactly the point of the article, btw. > Modules can add control structures (Try::Tiny), introduce new metaprogramming syntax (Moose), add operator overloading (overload)... it's very flexible. Technically they add functions, and the language allows you to use imported functions as control structures. This isn't so much to correct you as to clarify it for less familiar readers.
- kbenson 13y agoNo, it's a combination of allowing hash refs to be automatically created on access or assignment for complex data structures where it's implied. # False, key doesn't exist, doesn't print and doesn't create anything at that key location my $h; say "foo" if $h->{foo}; # Creates an empty hash ref at $h->{foo}, so $h->{foo} now evaluates to true in boolean context. $h->{foo}{bar} # True, prints "foo"; say "foo" if $h->{foo} # creates empty hash refs at bar and baz. say "what does this do?" if $h->{foo}{bar}{baz}{quux}; Works with array refs as well. Personally, I find once you understand it, it's fairly easy to guard against (even if it requires more code. e.g. say "foo" if $h->{foo} and $h->{foo}{bar}; # Assuming we know $h is a hash ref already. Edit: Typo and code block formatting
- __david__ 13y agoI almost got a patch pushed through to Perl to add a new operator that would help that problem (and the similar problem of nested objects who might be undef). Someday I'll have to dust it off and try again.
- codygman 13y ago"there's not much difference between it and PHP in terms of features" Are the Perl internals as pathological as PHP?
- singingfish 13y agoThis is absolute nonsense. Basically to describe the relation between perl and PHP, take all the good things out of perl 5.005 and you're left with PHP. Perl's internals to my knowledge are insane in a mad genius kind of a way. I would imagine that PHPs internals are pathalogical in a 'tramp smelling of urine' kind of way.