Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dongsturm
Feb 17, 2012
Yup, it's still used plenty in banks and fintech, but it's going the way of COBOL. Which I guess means I will finish my career as one of those weird old programmers who has perfect job security maintaining some bank's legacy Perl system.

Perl rocked, but Python won in the end. I can't see how it would be worth starting a career in Perl today, unless your company already used it.



Also, hi fellow Perlmonks dude! That was an amazing place for a while. Especially when a bunch of people were on there recommending everyone learn Scheme, and that taught me how to program properly, finally.

Adbot
ADBOT LOVES YOU

Achmed Jones
Oct 16, 2004



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.

larry wall worked at a lot of places - from what i can tell, pretty much any perl project that got big and gross enough hired him on at least as a consultant

you know what, maybe i'm thinking of randal schwarz. all i know is that one of them worked at a previous job (well before i worked there though)

lifg
Dec 4, 2000
<this tag left blank>
Muldoon

qntm posted:

Perl code:
print reverse "hello world";
# "hello world"

I’m surprised print isn’t trying to use reverse as a filehandle and output to it.

I used Perl professionally for a decade+, and I’m still surprised by the semantics at times. It’s one of my favorite languages, but it’s a bad language to build software in.

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."
I am actually starting to like perl for things like data-wrangling way more than using, say, something like bash.

Kind of in a weird phase of learning this for professional work but it also pays off that its just included in most *nix operating systems anyways.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Same. I’m trying to move away from using it professionally, but it fits really well into Unix pipelines so I still grab it for small tasks all the time

ExcessBLarg!
Sep 1, 2001
Y'all should move onto Ruby. Too bad the Ruby thread is also dead.

vote_no
Nov 22, 2005

The rush is on.

ExcessBLarg! posted:

Y'all should move onto Ruby. Too bad the Ruby thread is also dead.

The main advantage I find for perl and why I’m always reaching for it is that it’s installed on almost everything. If I have a system that has (or can have) ruby on it, why wouldn’t I use python or C++?

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."

vote_no posted:

The main advantage I find for perl and why I’m always reaching for it is that it’s installed on almost everything. If I have a system that has (or can have) ruby on it, why wouldn’t I use python or C++?

Its definitely this. I still often find CPAN modules stuff to be obnoxious, but I am kind of a baby in terms of programming

ExcessBLarg!
Sep 1, 2001

vote_no posted:

The main advantage I find for perl and why I’m always reaching for it is that it’s installed on almost everything.
I don't know if that's going to be the case indefinitely. I'm somewhat surprised that Perl hasn't been excised from Debian essential in favor or Python, but there's probably some scripts from the early 00s that debconf still makes use of or something. Certainly new stuff tends not to make Perl an essential dependency. Chrome OS ships with Python but not Perl, for example. But new stuff tends to not be for general-purpose computing.

vote_no posted:

If I have a system that has (or can have) ruby on it, why wouldn’t I use python or C++?
Well Ruby is a better language than Python for one, certainly so as a Perl replacement. C++ isn't a scripting language.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Ruby and Python are better languages for building software, but for throw-away Unix command line uses you really can’t beat learning either Perl or Awk+Sed.

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."
Are there any babby-level tutorials/write-ups out there on using Carton to manage Perl dependencies?

Feral Integral
Jun 6, 2006

YOSPOS

ExcessBLarg! posted:

Well Ruby is a better language than Python for one, certainly so as a Perl replacement

I never bothered with ruby, beyond reading about ror stuff like a decade or so ago. Curious as to why you think its a better language than snek

ExcessBLarg!
Sep 1, 2001
Ruby probably isn't better than Snek for its objective--I don't think it would run in 2 kB RAM.

Python wasn't a bad choice to base Snek on. It is a relatively small language. I'm kind of surprised they didn't just roll with Lua and call it a day, but Lua is weird too.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I thought it was Ruby who lost to Python, I remember there being a big war about that. I never considered Perl was in the fight. I learned PHP way back in the day and used it a lot, before switching to Ruby, used that a lot too. Man that feels like ages ago.

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."
I'm (slowly) doing Advent of Code this year with Perl and it has been a pretty nice exploration of different ways to do things, especially wrangling data quickly.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
In a Perl shoppe now. The product seems to have exactly the same level of technical debt and under/over designed issues that I've seen in Java and Python heavy solutions, but the language seems a good fit to focus on the data being managed. Even the newer PMs look at the code, so there don't seem to be many learning troubles.

Sadly some of the long tenured people are wrong on some of the details and reluctant to make improvements.

BattleMaster
Aug 14, 2000

I taught myself Perl last year because I've been using Linux a lot more and Perl comes in the standard Debian install. I've used it for a few things because it's honestly the fastest thing I know how to use for doing text stuff and it's also pretty easy to use to send arbitrary stuff over IP sockets. I don't like how it handles function arguments but at least the stuff I write is so simple I don't need functions. A+ would recommend if you have it sitting on your hard drive anyway

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

BattleMaster posted:

I don't like how it handles function arguments
It's rare to need to mess with prototypes in Perl, because there are few optimizations that result, but you get two basic approaches. Like shell scripts, arguments are positional, but they can be assigned individually:

code:

my ($ip,$count,$delay)=@_;

As programs grow into helpers and objects, it becomes much better to pass named lists:

code:

sub ping {
  my (%opt)=@_;
  $opt{count}//=4;
  ...
}

ping(ip=>'8.8.4.4',delay=>3);

Pimblor
Sep 13, 2003
bob
Grimey Drawer
I wrote a perl script professionally the other day cause I couldn't be arsed to figure out what I wanted to do in bash and I've been bitten by boxes that have python2 but not 3 and vice versa. I did this to avoid ruby and puppet modules and stuck it in an after install step in an RPM instead.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
Ooo part of an RPM even. I haven't dinked with building RPMs in about ten years.

Bash takes a different mindset; it can be a fun exercise.

Here's a fun one I didn't know until recently. You know how sed has a range operator, such as /open/../close/d ? It bleeping exists in Perl as well. :clint: In list context the .. range operator generates the range, duh, but in scalar context it's a boolean flip-flop operator. You can even do !defined(blah) .. /regexp/ and similar things, multiple instances without collision (ie nested loops work).

:3:

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
Random recent find, file test functions are automatically conjunctive. IE, these are the same:
code:

(-f $file) && (-w $file) && (-z $file)
(-f -w -z $file)

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

PhantomOfTheCopier posted:

Random recent find, file test functions are automatically conjunctive. IE, these are the same:
code:

(-f $file) && (-w $file) && (-z $file)
(-f -w -z $file)

:aaaaa:

I've been using Perl on and off for nine years and I never knew this, nor apparently any coworker at any company I've worked for.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
For some reason I've always split on newlines when using qx, which is silly since it automatically splits on the input record separator in list context.

code:

foreach my $line (split("\n",qx/blah/))
foreach my $line (qx/blah/)
Same, except the latter is more portable since the IRS follows the system.

Startyde
Apr 19, 2007

come post with us, forever and ever and ever
perl is awk++ (derogatory)

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Startyde posted:

perl is awk++ (derogatory)

:chef:

https://perldoc.perl.org/perlvar posted:

Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
Durr

code:

$flag = "-cat";
print -$flag;
:agesilaus:

duck monster
Dec 15, 2004

Nolgthorn posted:

I thought it was Ruby who lost to Python, I remember there being a big war about that. I never considered Perl was in the fight. I learned PHP way back in the day and used it a lot, before switching to Ruby, used that a lot too. Man that feels like ages ago.

Oh Perl stopped being a major player a long long time ago, a combination of people finding other languages (ruby for a while, then python) a bit more ergonomic to maintain without having to learn too much about the language itself. Its a powerful multifaceted toolbox of a language. But frankly most older Perl is a loving nightmare to maintain unless you live breathe and dream in regex.

Feral Integral posted:

I never bothered with ruby, beyond reading about ror stuff like a decade or so ago. Curious as to why you think its a better language than snek

Rubys strength is its weakness. Its really great for defining little DSLs in and creating highly magic based libraries. The problem with magic though, is when it goes wrong, its loving impossible to debug. And Rubys killer app, Rails, was the king of that. If you made a NATO standard regulation web app, that wasnt too dependent on its awful ORM, it was phenomenal. But as soon as poo poo gets weird in your requirements and you have to color outside the lines, Rails kinda falls apart conceptually and suddenly those neat natural-languageish lines turn into a metaprogramming clusterfuck

Productiveity wise though it'll clean the clock out of any language you could throw at it. Honestly, the hipsters abandoned Ruby for NodeJS because most of them are loving stupid. Its no wonder Python took off. NodeJS creates unmaintainable messes, and Rails just isnt cool anymore. Python was innevitable (yes I know its probably the oldest language of all of them. The hipsters dont know that)

duck monster fucked around with this message at 15:31 on Oct 27, 2023

lifg
Dec 4, 2000
<this tag left blank>
Muldoon

duck monster posted:

Oh Perl stopped being a major player a long long time ago, a combination of people finding other languages (ruby for a while, then python) a bit more ergonomic to maintain without having to learn too much about the language itself. It’s a powerful multifaceted toolbox of a language. But frankly most older Perl is a loving nightmare to maintain unless you live breathe and dream in regex.

It’s fun to think about the evolution of languages, and how each evolves to fit a niche, and has to continue to evolve or die. Perl 5 lost almost ten years of progress when it decided to put all changes on hold while waiting for Perl 6, and that’s when Python and Ruby just took over.

biznatchio
Mar 31, 2001


Buglord
Perl diving headfirst into the Osborne Effect and then sleeping for a decade certainly didn't help, but I agree that the core reason Python and Ruby took over is because they have easier to read syntax. TMTOWTDI is a great philosophy until you discover it means to understand everyone else's code that you need to know every dark corner of the language; and that's a huge drag on adoption in every niche outside of single-maintainer/one-off scripts.

Pimblor
Sep 13, 2003
bob
Grimey Drawer

duck monster posted:

Oh Perl stopped being a major player a long long time ago, a combination of people finding other languages (ruby for a while, then python) a bit more ergonomic to maintain without having to learn too much about the language itself. Its a powerful multifaceted toolbox of a language. But frankly most older Perl is a loving nightmare to maintain unless you live breathe and dream in regex.

Rubys strength is its weakness. Its really great for defining little DSLs in and creating highly magic based libraries. The problem with magic though, is when it goes wrong, its loving impossible to debug. And Rubys killer app, Rails, was the king of that. If you made a NATO standard regulation web app, that wasnt too dependent on its awful ORM, it was phenomenal. But as soon as poo poo gets weird in your requirements and you have to color outside the lines, Rails kinda falls apart conceptually and suddenly those neat natural-languageish lines turn into a metaprogramming clusterfuck

Productiveity wise though it'll clean the clock out of any language you could throw at it. Honestly, the hipsters abandoned Ruby for NodeJS because most of them are loving stupid. Its no wonder Python took off. NodeJS creates unmaintainable messes, and Rails just isnt cool anymore. Python was innevitable (yes I know its probably the oldest language of all of them. The hipsters dont know that)

Ruby at least still lives on in godawful puppet code, so we have that at least.

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."

Pimblor posted:

Ruby at least still lives on in godawful puppet code, so we have that at least.

And Chef! https://docs.chef.io/ruby/

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
But this is the Perl thread, so we love Perl here. As with any language, you get to maintain crap code if you write crap code, but when you adopt better patterns you get to enjoy beautiful code.

Perl, as many like to point out, has more than one way to do things, so you are free to adopt a code organization and presentation that matches the needs of the project. Procedural? Yep. Class based? Yep. Functional? Yep. Loaded up with 75 libraries and three lines of code? Yeap, even that.

It's so straightforward - rather, conditions, loops, flow control, are "universal", duh - that I worked with TPMs who filed ticket requests with code details and references. I never saw that at the Python, Ruby, and Java shops. They couldn't even find the relevant code.

Rooney McNibnug
Sep 2, 2008

"Life always hopes. When a definite object cannot be outlined, the indomitable spirit of hope still impels the living mass to move toward something--something that shall somehow be better."
I write a lot, if not most, of my API scripts in Perl these days

Soricidus
Oct 21, 2010
freedom-hating statist shill
I wrote a 900-character Perl one-liner the other day and it worked on about the 30th attempt, life’s good

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
It sounds perfectly acceptable, but likely represents poor planning, particularly when you find you need to do the same thing next week with slight variation.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
The Benchmark module has a subtle imperfection: It finds a baseline runtime for an empty eval based on the type of underlying tests but does so only once. Delays at that time may result in later runtimes being reported as negatives, particularly when using the direct timing functions (instead of cmpthese).

Obviously benchmarking comes with a ton of caveats, but it's common to build representative baselines, which themselves require statistical measurement. Reporting and subtracting that runtime is likely to make more sense when performance profiling compared to getting some tests with negative average runtimes.

I really like how easy it is to quickly benchmark in Perl but this was an interesting choice.

If you see some negative times when using the timing functions of Benchmark coupled with timediff, this is the likely culprit. It's much less likely that your clock is jumping backwards.

Pimblor
Sep 13, 2003
bob
Grimey Drawer
It turns out our super cool patching dashboard for thousands of machines world wide is broken because a 20 year old perl script was using Net::Telnet to puppetstring ssh connections and there are over 200k loc in it.

frumpykvetchbot
Feb 20, 2004

PROGRESSIVE SCAN
Upset Trowel
In 1997 I got my first digital camera. I also discovered ImageMagick and perl that year, and so I built a basic image processor out of perl and Image::Magick to automate managing my photo folders of JPEGs and generating thumbnails and HTML catalog views I could view in Netscape.

Almost 30 years later I still use and tinker with this system, but now it lives on a server on my network and manages a photo collection of 400,000 images I've taken in the decades since. It handles archiving and metadata for all my terabytes of raw source files, version control for edited 16-bit wide-gamut JPEG2K master versions (from Photoshop and Lightroom), and still after all these years it uses the ever-dependable Image::Magick to export a variety of viewing and sharing versions of the masters in standard formats and color spaces. It's all glued together with watch folder automation.

I still consider it a perl project though in recent years a couple of heretical python plugins have crept in to use some AI models for auto-generating keyword search terms and image descriptions, recognizing people and tagging features and regions of interest.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
Tis interesting that pointers will always cause problems for programmers. One of the most frequent syntax questions I get from our software peeps is their confusion about accessing things in basic and object types. They get confused because there are lots of places in our code where people have chosen to use references and arrow dereferencing.

I get the impression that the mid engineers really don't know what's happening and are just trying things until it works. Sadly, but I still see lots of ahha moments when people are sharing examples, doing code reviews and the like.

It's amazing how consistent the original syntax is after all these years and language requests.

Adbot
ADBOT LOVES YOU

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Rookie perl question:

Given a string like '192.168.0.1:21,22,80,445,1432,30220' what would be a slick perl way to check if port 22 is in that string?

I can write it the naive way but I'm curious about a short-hand way to do it.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply