Live data from Hacker News

Perl first commit: a “replacement” for Awk and sed

github.com

211–220 of 261 posts

Re: Perl first commit: a “replacement” for Awk and sed

#211
post #174

Earlier quoted context omitted.

Which languages are most common in these systems?

Well, I'm not sure about everywhere but, the work I'm finding is ASP3.0 (IIS6.0) and VB6 (more rare) also Perl and PHP. Many of these projects were started in the late 90s. They are internal systems (billing automation, internal work-tracking, custom "ERP"). Nothing exciting, just old shit that makes money in a non-tech business. I find the work on LI, and I show up when folk search for these olds skills. But I know…

Do you find any of these legacy system clients are open to having their system upgraded to a modern version of the same or related language, eg. .Net for ASP? After all, it wouldn't involve a significant change in the business logic and most esablished languages are more or less backwards compatible.

Re: Perl first commit: a “replacement” for Awk and sed

#212

Earlier quoted context omitted.

I once went looking for something like Ansible that was implemented in Perl. Does such a thing exist? I think declarative system orchestration got popular well after perl's popularity declined. In any case, I did not find anything.

Rex: https://metacpan.org/pod/Rex never used it but

Thanks!

Re: Perl first commit: a “replacement” for Awk and sed

#213
post #207
post #54

The next time I need awk or sed, whatever I end up writing I’ll submit to chat gpt and ask it to rewrite it in perl so I can compare. I’m curious because so many people (well, enough people anyway) speak so highly of perl’s text processing capabilities. If it’s such a great tool, then I want to use it too. Edit: one plus is that perl is as ubiquitous as awk and sed. It was there the whole time and I didn’t even reali…

This sounds interesting! The main reason I moved to perl instead of sed or AWK is for better control. Shell scripts don’t differentiate between variables and data (anyone else still having nightmares from trying to escape quotes and meta chars in a shell?). Perl gives you all the simple features from sed or AWK and adds useful (maintainable) foreach iterators, arrays, hashes, etc. Recommend using Strict mode if you a…

Thank you for the tip re: strict! Escaping - that's definitely a sore point. I feel like I get tripped up by embedded double quotes way too often - does perl have a good way to handle them?

Re: Perl first commit: a “replacement” for Awk and sed

#214
post #133
post #79

Earlier quoted context omitted.

csh was a decent interactive tool, but not great for scripting. Bourne shell had the right idea but there were so many bugs in various corners of it (I still sometimes end up writing "test "x$foo" = "xbar" even though shells that need that are long gone). If you can depend on a recent bash and use shellcheck, then it's actually quite a pleasant programming environment, with fewer footguns than one might think. (I wan…

Mostly agree. The modern shell scripting environment is much more robust than 30 years ago, with ShellCheck and some sane defaults, as you say. I also find it pleasant, once you get over some of its quirks. As for managing libraries, that's true, but you can certainly import and reuse some common util functions. For example, this is at the top of most of my scripts: set -eEuxo pipefail _scriptdir="$(dirname "$(readli…

I haven't seen -E (aka -o errtrace) before, but it looks like a useful addition to the standard-ish -euxo pipefail.

Moreover, it's existence being required explains why my error handling, recently, wasn't working as expected.

Re: Perl first commit: a “replacement” for Awk and sed

#215
post #177
post #8

Earlier quoted context omitted.

That might be true culturally, but it's not true technically. Once you know a bit of Perl (including some command line switches like -e, -n, -a, -l, -p, and -i) you will be able to do just as easily everything you used to do in awk and sed, but with a more powerful foundation so you have the flexibility to go further.

"Minimal Perl" by Tim Maher is unrivaled for this.

Thank you for mentioning that book - I'm very interested in how perl can replace awk and sed and even grep(!) - I use grep multiple times a day, awk maybe a few times a week, and sed very rarely. I think I'm in the target demographic for this :)

Re: Perl first commit: a “replacement” for Awk and sed

#216

Earlier quoted context omitted.

It also seems like the core perl developers did not want to acknowledge the importance of web/html. They did not add support for encoding/decoding html entities or URLs were added. No standard modules for this. No easy method of making html pages from a URL request besides running as CGI. This made perl lose to php which made it very easy to make a simple "Hello, world" page. php would never had any traction if perl…

>They did not add support for encoding/decoding html entities or URLs were added. It's certainly not in core, but look how PHP flubbed that up (html_entity_decode, htmlspecialchars_decode, htmlentities). >No standard modules for this. Obviously there are, https://metacpan.org/pod/HTML::Entities The changelog goes back only to 1998, where it states, 2.14 1998-04-01 HTML:: modules unbundled from libwww-perl-5.22 That w…

1998 is too late, it was all over. PHP was used on over 50k sites by mid-1997. https://ifj.edu.pl/private/krawczyk/php/intro-history.html

Netscape Navigator was released late 1994, so this was the point of time where perl developers should have seen the light.

Re: Perl first commit: a “replacement” for Awk and sed

#217
post #179

Earlier quoted context omitted.

>awk is a fantastic command line application that is useful for filtering, basic computations and transformations that other basic utilities (e.g. cut, sort, etc.) + grep don't (readily/easily) provide. All true. But awk is also a programming language, not just a command line application or utility. It has conditionals, loops, regexes, file handling, string handling, (limited) user-definable functions, hashes (associ…

> In fact, the name of the original book about awk is The Awk Programming Language. Great book. I read it after it was so enthusiastically endorsed here on HN. A lot of people said it was worth reading just to take in the excellent technical writing style of Brian Kernighan. I would offer a strong second to that.

Cool. Yes, his style is good in his other books too, like K&R (C), K&P (Unix), and GOPL (Go), and The Practice of Programming.

Re: Perl first commit: a “replacement” for Awk and sed

#218

When perl came out we were living in horrific times. You had the choice of either Bourne, C or Korn shell. Automation was glued together in one of these with a series of grep, awk, sed, ls, test, commands glued together. Anything more complicated was written in C and called from one of these things. Perl in one stroke collapsed the programming of C, text manipulation, the capabilities of all of the Unix utilities, an…

Yes, writing shell scripts calling awk and sed was awful, just an aesthetic nightmare to work with. Properly quoting strings was always problematic, and while Usenet was available there wasn't a plethora of information like nowadays. This was a few years before Bash was released.

Through my use of Usenet I learned that a better reader program was available called 'rn', which I downloaded and built. It had an amazing handwritten install script (autoconf was years off) which could automatically configure and build rn on any *NIX system. All developed by a fellow named Larry Wall.

rn was truly a joy to use and made reading Usenet swift and efficient. It would get updated with the fixes that came across Usenet that I'd apply using the clever 'patch' program, also written by Larry Wall.

Based on my experience with his other software, when Larry Wall released Perl on Usenet I immediately downloaded, built, and started using it. As promised, for scripting things not requiring a C program, it was massive improvement. Version 2.0 came out and brought many great new capabilities.

I wasn't writing software while versions 3 and 4 came out; I started using it again after version 5 and the appearance of CPAN. Over the years I've used Perl extensively for task automation and data wrangling.

Python now dominates Perl's niche because it's easier to learn and interfaces better with C. It's also less flexible, which compared to Perl is a virtue. One of Perl's mottos is TMTOWTDI—there's more than one way to do it. But many of them are bad. Much of Perl's poor reputation ("line noise") stems from this.

But when Perl was released it was a revelation, like a drab day when the clouds suddenly part letting warm sunlight pour down on the land.

Re: Perl first commit: a “replacement” for Awk and sed

#219
post #76

Earlier quoted context omitted.

There is some question whether CTAN (for TeX) or CPAN was the first big library. It was pretty close. I was involved tangentially with the guys in the UK who were setting up the first pass at CTAN as the administrator of the ymir.claremont.edu archive and I remember one of the things that they came up with back then was that you could do an FTP get of any directory and get back a zip archive of its contents which was…

>There is some question whether CTAN (for TeX) or CPAN was the first big library. I'm not in this space, but the similarity in names made me wonder if these would really have started around the same time, with an unclear "dependency order", so I reached for a search engine, and according to Wikipedia, CPAN (1993) is based on CTAN (1992).

See also The Timeline of Perl and its Culture https://history.perl.org/PerlTimeline.html

Re: Perl first commit: a “replacement” for Awk and sed

#220

Earlier quoted context omitted.

Moreover, as often as people joke about the readability of Perl code, that's entirely a function of the developer. I've easily written tens of thousands of lines of Perl, and not a single person has complained about difficulty reading or maintaining that code. Why? Because I apply all the usual best practices for code hygiene that apply to any language. Frankly, I think most people are just repeating a meme they hear…

> that's entirely a function of the developer. I would argue the same of sed/awk; you can write an unmaintainable mess, but you don't have to.

Oh sure. IME Perl just pulls it all together into a much more convenient, all-in-one package that has all the libraries and tools you need to build anything from small scripts all the way up to large projects.
Post reply on HN