|
I saw that the previous Perl thread is long dead, so I want to start a new one. I've been writing a solo (mostly text processing) project in Perl for a couple years now, and I loving love it.
|
# ? Dec 30, 2019 05:15 |
|
|
# ? May 27, 2024 03:16 |
|
get a therapist, op
|
# ? Dec 31, 2019 22:04 |
|
My condolences.
|
# ? Dec 31, 2019 23:30 |
|
My brother in law works in Perl and he thinks it's the dog's bollocks, but I wouldn't want to work in Perl any more than I'd want to work in PHP. Being fair though I expect it's better than PHP though (wouldn't be difficult). Brother in law comes out with stuff like "Perl 6 is the only language with true unicode support" (I'm definitely failing to quote him verbatim here, but he has a habit of coming out with provocative statements that invite disagreement). Why should anyone fancy doing a project in Perl, OP, and not some other scripting language like Python or Ruby? Isn't it a bit of a dead end if you want to learn languages you can use to get a job?
|
# ? Jan 1, 2020 02:12 |
|
I already know languages that can get me a job, but I chose to use Perl for myself. I like Perl because it's pretty likely I can run it on another machine without some dependency issue. Because it a glue language, there are not likely to be breaking changes in future versions. Another (optional) portion of my project is PHP, for similar reasons--it usually just kind of works. I'm aiming for easy installation and low maintenance, so that's why I chose Perl. I also hate whitespace syntax, so Python was out until I figured out I can do commented braces.
|
# ? Jan 4, 2020 08:52 |
|
Perl code:
|
# ? Jan 4, 2020 14:27 |
|
qntm posted:
explain this. I want to know how this programming language can be so bad.
|
# ? Jan 4, 2020 15:31 |
|
Actually to be honest that post is fairly mean-spirited and I apologise. This is a thread for people who like Perl and people liking Perl doesn't hurt me so I'm going to back off. To answer your question, Perl has a unique feature known as context-sensitivity. Every Perl expression is evaluated in one of two contexts, list context or scalar context. The context is provided by the code surrounding the expression, and the expression can (and frequently does) return different results depending on that context. In this case the expression in question is reverse "hello world". The print statement evaluates all of its arguments in list context. In list context, the reverse function treats all of its arguments as entries in a list and then returns a reversed list. In this case the list has a single scalar entry, the string "hello world", and so the returned value is the same single-entry list again, which print then prints out. The my $string = assignment evalutes the right-hand side in scalar context. In scalar context, reverse treats all of its arguments as a single scalar - casting them to strings and concatenating them all together if necessary - and then returns a single reversed string.
|
# ? Jan 4, 2020 18:42 |
|
qntm posted:Actually to be honest that post is fairly mean-spirited and I apologise. This is a thread for people who like Perl and people liking Perl doesn't hurt me so I'm going to back off. Thats interesting. Is there an example of idiomatic Perl that uses this? Cause its still kindof hard to wrap my head around.
|
# ? Jan 4, 2020 19:19 |
|
qntm posted:Perl has a unique feature known as context-sensitivity. Every Perl expression is evaluated in one of two contexts, list context or scalar context. This sounds extremely bad and needlessly confusing, and likely to be a huge source of bugs. It seems to me that it would be much better to have the user explicitly indicate what sort of behaviour they want than try to be clever and let them change the program's behaviour subtly through context. Can someone explain why I'm wrong?
|
# ? Jan 4, 2020 20:57 |
|
Hammerite posted:This sounds extremely bad and needlessly confusing, and likely to be a huge source of bugs. It seems to me that it would be much better to have the user explicitly indicate what sort of behaviour they want than try to be clever and let them change the program's behaviour subtly through context. Can someone explain why I'm wrong? You're not really wrong, but Perl's gimmick is preferring idiomatic shorthand convenience over almost everything else, and the differences are usually not subtle. There's very intentionally no consistency whatsoever in what the builtin functions that can return lists do in scalar context - the documentation uses the (in)famous phrasing "in general, they do what you want, unless you want consistency". localtime() returns a string representation instead of a C-like time struct if used in scalar context. map() - which is more like what many other languages would call flatMap since each input element can map to any number of output elements, and in fact even to zero elements - returns the number of elements of the resulting list rather than the list itself. Some of the file I/O functions like readline() and readdir() return the next entry and advances the filehandle pointer in scalar context, while using them in list context reads until EOF and returns a list of files/lines/whatever, so they're stateful in one context but not really in the other. splice() - which splices like an array like Array.splice() in JavaScript - returns the last element removed in scalar context, or undefined if no elements were removed. sort() in scalar context has undefined behavior. In Perl's defense though it's usually not hard to see what the context is because of the sigils that prefix variables - scalars are prefixed with $, arrays with @. You declare the context with the sigil, like Perl code:
Perl code:
Another example of this focus on idioms is the return values from low-level syscalls that return 0 or a positive integer on success but a negative value on failure. In languages with modern exceptions you'd write something like code:
Perl code:
Perl is full of little weirdnesses like this and that's why it's fun. It's a very old language, which shows, and it has wildly different design goals from basically any language that's in common use today, but that's part of the charm. Unlike some of the more obnoxious languages like PHP or JavaScript that are full of weird and annoying issues because of historical mistakes, Perl isn't weird by accident - it was very intentionally designed to be weird. It was the first language I learned back in the day and I have quite a bit of fondness for it. Wouldn't want to work with it, though. TheFluff fucked around with this message at 17:41 on Jan 9, 2020 |
# ? Jan 9, 2020 17:11 |
|
Man, writing that up made me remember how hilarious Perl is. Did you know that substr() can be used as the left hand side of an assignment?Perl code:
|
# ? Jan 9, 2020 17:47 |
|
If you take a list, and use it in scalar context, you get the number of items in it. Pretty useful in a bunch of places. But what if you have one of these functions that works differently in scalar context, but you want to call the listy version and then count how many values there are? You could just use a temporary, as described above, but the true Perl master would use the goatse operator =()= (alternatively written =( )=, if you prefer authenticity over compactness). For example, to count how many times a regex matches a string: code:
|
# ? Jan 10, 2020 02:04 |
|
I think you'll find it should be my $count ≗()= $str =~ /myregex/g
|
# ? Jan 10, 2020 14:35 |
|
I remember I wrote an IRC bot about a decade ago in Perl and boy howdy is it a weird language. Being such an old language though (Perl 5 was already over 25 years old at the time) it's very easy to just code until you run into a problem, Google the problem, find a solution and keep working. On top of that, being a language where the only real idiom is "do it however the gently caress you want" there's relatively few arguments about what the best way to accomplish a particular task is so you don't get bogged down in the StackOverflow-style arguments about how x or y solution is "better" with very little elaboration on why. In my opinion those are attractive (and underrated) qualities about a language for an inexperienced programmer. Perl is easier to get started with. As mentioned above, Perl is also designed to be weird, rather than being weird by mistake, and the unintentional weirdness tends to get corrected so the language ends up having fewer annoyances for an individual programmer over time than something like PHP. Perl is easier to keep using. I wish I still had some of the source code for that bot so I could post it in here and be laughed at. I remember I talked in an IRC chat about a problem I was trying to solve and the weird old dude who did the original graphics layer overhaul for Dwarf Fortress called me an idiot and did something in a single line that had taken me 2 functions and a 2D array and I still hadn't actually cracked it. Then he tried to encourage me to use an external atomic decay RNG to roll dice for some reason. Those were the days.
|
# ? Jan 10, 2020 21:08 |
|
that explanation made me love Perl even more. i love quirky languages with fun features and bizarre design goals, and embracing the ambiguity rather than it feeling like arguing with a reddit user who says "well, actually" every post and links to yourfallacyis.com
|
# ? Jan 10, 2020 22:54 |
|
It definitely comes with caveats. Asking for help can get you ten different answers from three different people. On top of that, 10 years ago Raku didn't exist yet so you'd occasionally go to download something from CPAN and it would have some bizarro OO implementation with hostile syntax. That still happens but people who actually want OO Perl can do more than just write terrible packages now.
Makrond fucked around with this message at 03:13 on Jan 11, 2020 |
# ? Jan 11, 2020 03:09 |
|
Thank you all for reminding me all the reasons to love Perl.
|
# ? Jan 16, 2020 00:08 |
|
My brain still does not want to accept Perl Idioms with &&, II. Not like C-style, or most of what I've seen.code:
So if you have something like: if( obj.isTrue() && obj ) { ... } If obj.isTrue() equals true, then it's going to ignore obj after &&. I know this is obvious those familiar with the language, but it's a notable difference that may not be too obvious to those starting out.
|
# ? Jan 16, 2020 18:00 |
|
That's exactly how it works in every other language though? Using side-effecting expressions there is weird, but that's on the person writing side-effecting expressions in that context.
|
# ? Jan 17, 2020 03:39 |
|
That's exactly the kind of code I avoid writing.
|
# ? Jan 18, 2020 09:53 |
|
Isn't Perl supposed to be, like, profound unpleasant to write?
|
# ? Jan 19, 2020 12:42 |
|
Ape Fist posted:Isn't Perl supposed to be, like, profound unpleasant to write? Where did you get that idea? It's completely the opposite. Perl is loving hilarious to write, you'll sit there giggling to yourself about whatever cleverness you might've come up with. It can be really annoying to read though because there are so many ways to express the same thing and there are many subtleties hidden everywhere.
|
# ? Jan 19, 2020 19:18 |
|
Perl still rules, but looking at the Perl I wrote years ago makes me want to barf. e: the first thing I wrote at my current job was a program to generate EEPROM images for a bunch of different product configurations by parsing a couple of Excel spreadsheets and spitting out a bunch of Intel hex files. I used Moose for the OO system and did all the heavy lifting with a couple of CPAN modules. Got the whole thing working and bug-free in about a week, which blew the socks off the guy I was reporting to at the time, who had previously thought we were going to have to delay product launch for a month while the firmware dude on that project got all the configs made. I recall the unit test report that prove generated also impressed some people. Good times back then. Blotto Skorzany fucked around with this message at 21:22 on Jan 21, 2020 |
# ? Jan 21, 2020 21:18 |
|
Perl5 is the best bad language. I still use it for little scripts and glue and it’s good
|
# ? Feb 21, 2020 12:37 |
|
I still love Perl as well. One of the first non-work things I did with Perl was build a basic forum with it. I feel compelled to revisit the idea given that I'm currently confined to my home and furlough'd. Perl 5 that is. I still haven't looked at Perl 6.
|
# ? Apr 1, 2020 23:14 |
|
I loved Perl when, in 2010, I took a sysadmin job at a university and the password database glue script my friend - a smooth brained Perl wizard - wrote in high school as an intern in 1998 was still working flawlessly in the heart of the identity management system, running every single time anyone or anything needed to authenticate. My understanding is that it still runs to this day. I hate Perl whenever I have to see, write, or understand it.
|
# ? Apr 17, 2020 01:52 |
|
Blotto Skorzany posted:Perl still rules, but looking at the Perl I wrote years ago makes me want to barf. At my first real job we once needed to scrape some data off web for a project. It wasn't really my responsibility but both I and a CS PhD type colleague said we'll have a crack at it. I, despite being a terrible programmer, had the script chugging along in an hour or two, while the guy was still writing parser factory-factories or some poo poo.
|
# ? Apr 19, 2020 19:49 |
|
As someone who lives in PHP Land, I've though about going over to the Perl boat, but I'm afraid of CPAN that thing scares me as much as composer does. Overall, what are the main language differences between the two?
|
# ? May 10, 2020 03:45 |
|
Alright, I have a Perl question. Well, actually two if you include "why am I using Perl". I'm using an install of Perl 5.20.1 on AIX Unix and I am being told that the following code is wrong: code:
Ultimately I need to apply a Passive argument to this constructor as well but I removed it to ensure that wasn't the cause. This is basically straight lifted from their documentation and I have no idea why it's failing. I've tried changing the server to a variety of values including the IP address, tried single quotes instead of double. Help. PierreTheMime fucked around with this message at 22:30 on Jul 12, 2020 |
# ? Jul 12, 2020 22:27 |
|
Gonna be honest, Raku looks cool, but that's probably because I've never written a line of Perl in my life.
|
# ? Jul 12, 2020 23:40 |
|
PierreTheMime posted:Net::FTP: connect: Invalid argument at line 4. So apparently this issue was that the FTP host was refusing the connection and my code was not invalid. The exact same code to another server worked just fine. Very helpful error message
|
# ? Jul 13, 2020 03:46 |
|
I can’t believe Apple is planning to remove perl from macos, thereby ruining its status as “scripting tool that’s better than sh+sed/awk and always predictably there on every unixy platform”
|
# ? Jul 19, 2020 08:31 |
|
This thread is bringing back a lot of memories. My first programming job in like...1999 involved a lot of Perl. It was my daily driver for several years. I even used to answer questions on perlmonks. I rarely use it now and have forgotten more than I once knew, but even so - if I need to quickly transform a text file into some other format, Perl is still the first thing I reach for. It's like a Marshall amp - it does ONE THING really, really, really well. But as a general purpose language? Eh. Way too many better options these days. I'm most pissed about my regex skills rusting. I can still bust out a clever one from time to time, but I can no longer just spit out some JEDI poo poo on the first try. Sad.
|
# ? Sep 5, 2020 12:52 |
|
The only time I have used perl was for a coding assignment for a junior developer job like 6 years ago. I didn't know perl so I was trying to learn it for the assignment, I think I made it about 30 minutes and starting to delve in to sigils before deciding that no job could be worth that. *Don't take it as a knock if you like the language, I'm sure it's a lot better if you're trying to learn it from basics like a book, instead of for a coding assignment.
|
# ? Sep 5, 2020 19:56 |
|
Generally speaking, what is the current market like as a Perl developer? I know the joke of "Perl is dead" etc... but for those of you who are comfortable with Perl, is there work to be had? Are Junior Developers in Perl still a thing these days?
|
# ? Feb 12, 2021 05:12 |
|
Much as I have a soft spot for Perl, I can’t imagine wanting a job working with it today. You’d either be stuck in hell maintaining the old Perl code so bad nobody dares port it, or you’d be working with the kind of person who thinks it’s a good idea to start major new projects in old unpopular languages, and neither of those sounds fun
|
# ? Mar 11, 2021 12:17 |
|
Soricidus posted:Much as I have a soft spot for Perl, I can’t imagine wanting a job working with it today. You’d either be stuck in hell maintaining the old Perl code so bad nobody dares port it, or you’d be working with the kind of person who thinks it’s a good idea to start major new projects in old unpopular languages, and neither of those sounds fun Yeah, that's what I figured. I enjoy learning enough Perl for small personal scripts but I can imagine working on old enterprise software is not quite as fun.
|
# ? Mar 11, 2021 14:09 |
|
Craigslist is written in perl. Larry Wall himself works (worked?) there. It might be a good place to work if you like perl.
|
# ? Mar 15, 2021 10:41 |
|
|
# ? May 27, 2024 03:16 |
|
FastEddie posted:Craigslist is written in perl. Larry Wall himself works (worked?) there. It might be a good place to work if you like perl. Oh theres plenty of places that still use Perl. You just need to have at least one backpacker murder conviction in your resume before you'll be offered one.
|
# ? Mar 19, 2021 02:28 |