EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: PKTKS on May 28, 2022, 10:21:06 am

Title: PERL 7 for what it really matters
Post by: PKTKS on May 28, 2022, 10:21:06 am
PERL  (besides all attempts...)  is by far not dead...

http://blogs.perl.org/users/psc/2022/05/what-happened-to-perl-7.html (http://blogs.perl.org/users/psc/2022/05/what-happened-to-perl-7.html)

Paul
Title: Re: PERL 7 for what it really matters
Post by: gmb42 on May 28, 2022, 08:24:50 pm
Random thoughts.

If Perl, and especially Perl 7, is ever the answer then the question is fundamentally flawed in the first place.

Time to stop beating that dead horse!

Most folks seem to agree: https://www.tiobe.com/tiobe-index/perl/ (https://www.tiobe.com/tiobe-index/perl/)

Perl isn't being killed off, it's dying due to lack of usefulness.
Title: Re: PERL 7 for what it really matters
Post by: cfbsoftware on May 28, 2022, 11:27:20 pm
Most folks seem to agree: https://www.tiobe.com/tiobe-index/perl/ (https://www.tiobe.com/tiobe-index/perl/)
Here's another another estimate of what 'folks' might be thinking:
Quote
Of course, determining the developer base of any particular programming language is not an exact science. "It can be hard to assess how widely used a programming language is," noted SlashData. Its figures are based on two pieces of data: the organization's own estimate of the number of software developers worldwide (which it puts at 26.8 million), as well as its bi-yearly surveys, which SlashData said reach "tens of thousands of developers every six months". So, there is some margin for error.
https://www.zdnet.com/article/top-programming-languages-most-popular-and-fastest-growing-choices-for-developers/ (https://www.zdnet.com/article/top-programming-languages-most-popular-and-fastest-growing-choices-for-developers/)
However PERL doesn't get a mention here at all. I don't use PERL myself but most of the other languages I use in my daily work don't get a mention either. Do I give a toss? ;)
Title: Re: PERL 7 for what it really matters
Post by: Foxxz on May 29, 2022, 01:46:18 am
Perl is one of the languages I started off with. It is concise and allows you to accomplish alot with minimum code. The language doesn't get in the way of allowing you to accomplish whatever. That ability comes with tradeoffs.

I hate python even though its all the rage. Don't force me into something ad petty as white-space code formatting. What a croc. And while we're at it, lets change the names of arrays and other common industry established data constructs.

Does Perl allow you to write sloppy and unreadable code? Yes. But if I cared in the first place I wouldn't have done it.
Title: Re: PERL 7 for what it really matters
Post by: SiliconWizard on May 29, 2022, 02:25:57 am
Perl is still being used, so no it's not dying, apparently.
If the tool does the job, what's the problem?
Title: Re: PERL 7 for what it really matters
Post by: brucehoult on May 29, 2022, 07:41:00 am
I use Perl 5 every single day. I have no interest in what they did to it in Perl 6. I guess I should look at 7, but I don't have high hopes.

Here's something I was just running a few minutes before I found this post:

Code: [Select]
Mac-mini:~ bruce$ curl http://hoult.org/bruce.ip 2>/dev/null | grep '\.' | perl -ne 'sub p {print "$s $n\n" if $n!=0} chomp; if($_ eq $s){++$n}else{p;$s=$_;$n=1}; END {p}'
103.152.127.142 125
103.152.127.143 480
103.152.127.142 283
103.152.127.143 3
103.152.127.142 1
103.152.127.143 37
103.152.126.179 537
103.152.126.178 16
103.152.127.164 600
103.152.126.144 62
103.152.126.145 180
103.152.126.144 262
103.152.127.166 247
103.152.126.147 11
103.152.127.163 441
103.152.127.162 74
103.152.127.163 64
206.83.116.202 1282

It goes on a bit longer than that. List of how in how many consecutive 15 minute periods I had the same IP number on Starlink, starting at the beginning of February.

If I want something perl'ish but with more conventional data structures and functions and so forth then I use Ruby.
Title: Re: PERL 7 for what it really matters
Post by: PKTKS on May 29, 2022, 08:17:40 am
2x of us

I dont like the things on PERL 6  and stick plain 5..  but it seems the steering folks want to veer things back to place

PERL  has no substitute

Paul
Title: Re: PERL 7 for what it really matters
Post by: magic on May 29, 2022, 09:40:05 am
I knew Perl 6 will be a flop when I saw their mascot :-DD
Or that the initial implementation was in Haskell.

Perl 5 is useful as it's available on virtually every Linux system and better suited to short scripts than some popular alternative.
I wouldn't use it for any "serious software", though.
Title: Re: PERL 7 for what it really matters
Post by: PKTKS on May 30, 2022, 08:24:59 am
Actually besides despite against all attempts to deprecate perl ..

You just can not compile install and keep a distro wo it...

The systemd party has been trying way too hard that

So far

Never really worked and PERL7 should put things back to normal

Paul
Title: Re: PERL 7 for what it really matters
Post by: Doctorandus_P on May 30, 2022, 01:33:01 pm
Some time ago I wanted to add a scripting language to my vocabulary (only used C and C++ before) and Perl seemed a quite nice candidate.

In the end I settled for python. I find it a quite distasteful language but I don't have much choice. It's used as the scripting language in almost every program I use (KiCad, FreeCAD,  Sigrok/Pulseview)

Good riddance of Python V2. That took at least 8 years too long to get rid of, but the horrible whitespace dependency still remains.
I once wanted to create a diff for a bug report of Meld. The error was a few missing spaces in the last line of a for loop, which dropped that line out of the loop.

But this is a pearl thread, so I'll shut up now.
Title: Re: PERL 7 for what it really matters
Post by: emece67 on May 30, 2022, 04:28:32 pm
.
Title: Re: PERL 7 for what it really matters
Post by: PKTKS on May 30, 2022, 06:16:17 pm
I use Perl 5 every single day. I have no interest in what they did to it in Perl 6. I guess I should look at 7, but I don't have high hopes.

Here's something I was just running a few minutes before I found this post:

Code: [Select]
Mac-mini:~ bruce$ curl http://hoult.org/bruce.ip 2>/dev/null | grep '\.' | perl -ne 'sub p {print "$s $n\n" if $n!=0} chomp; if($_ eq $s){++$n}else{p;$s=$_;$n=1}; END {p}'
103.152.127.142 125
103.152.127.143 480
103.152.127.142 283
103.152.127.143 3
103.152.127.142 1
103.152.127.143 37
103.152.126.179 537
103.152.126.178 16
103.152.127.164 600
103.152.126.144 62
103.152.126.145 180
103.152.126.144 262
103.152.127.166 247
103.152.126.147 11
103.152.127.163 441
103.152.127.162 74
103.152.127.163 64
206.83.116.202 1282

It goes on a bit longer than that. List of how in how many consecutive 15 minute periods I had the same IP number on Starlink, starting at the beginning of February.

If I want something perl'ish but with more conventional data structures and functions and so forth then I use Ruby.

Interesting...  ... never occurred to me using curl that way
.. with custom argument and custom sorting
put desired URL as argument

Code: [Select]
$s;$n=0; $\="\n"; sub p{ $fhs{$s}=$n if $n; $s=$_;$n=1;}
open PIPE, 'curl '.shift.'|' or die('PIPE Failed');
while(<PIPE>){ chomp; next unless m/\d+\.\d+\.\d+\.\d+/; ($_ eq $s) ? $n++:p;} p;
close PIPE; foreach (sort {$b cmp $a} keys %fhs) { push(@fhs,$fhs{$_}."\t".$_); }
foreach (sort {$a <=> $b} @fhs) { print; }

1       206.83.116.210
1       206.83.116.151
1       103.152.127.142
2       206.83.116.61
3       206.83.116.253
11      103.152.126.147
16      103.152.126.178
36      206.83.116.218
37      103.152.127.143
64      103.152.127.163
74      103.152.127.162
91      206.83.116.6
97      206.83.116.232
180     103.152.126.145
187     206.83.116.142
191     206.83.116.132
193     206.83.116.228
247     103.152.127.166
262     103.152.126.144
372     206.83.116.192
537     103.152.126.179
559     206.83.116.201
580     206.83.116.166
600     103.152.127.164
660     206.83.116.240
1784    206.83.116.202

PERL made me rethink the way I think..

btw: this wrap is still a plain oneliner

Paul
Title: Re: PERL 7 for what it really matters
Post by: brucehoult on May 31, 2022, 02:09:48 am
It's of course nice that you can do it all inside perl using a pipe and hash or array but keeping much of it in bash works well for me.

I can get effectively the same output as yours by just appending | sort -nk2 to my bash line. Or get actually the same as yours by changing the print in the perl and using | sort -nk1. Or  | awk '{print $2"\t"$1}' | sort -nk1 (or perl instead of awk)
Title: Re: PERL 7 for what it really matters
Post by: SiliconWizard on May 31, 2022, 02:40:44 am
I admit I'm personally no good at PERL and would thus use another tool for that kind of stuff, but if you're reasonably proficient in it, then just use it. It's a tool that is not likely to die anytime soon, contrary to what some people prophetize.
Title: Re: PERL 7 for what it really matters
Post by: PKTKS on May 31, 2022, 02:48:30 pm
It's of course nice that you can do it all inside perl using a pipe and hash or array but keeping much of it in bash works well for me.

I can get effectively the same output as yours by just appending | sort -nk2 to my bash line. Or get actually the same as yours by changing the print in the perl and using | sort -nk1. Or  | awk '{print $2"\t"$1}' | sort -nk1 (or perl instead of awk)

PERL just gives a banana for that kind of concern...

Both uses on a same oneliner  can be piped or called either way..

This time with IPV4SORT custom sorting

Code: [Select]
$\="\n"; $s='';$n=0; sub p { $fhs{$s} = $n if $n; $s = $_; $n = 1; }
if ( scalar @ARGV ) { open PIPE, 'curl '.shift.'|' or die('PIPE Failed');
while(<PIPE>) { chomp; next unless m/\d+\.\d+\.\d+\.\d+/; ($_ eq $s)?$n++:p; } p; close PIPE;
} else {
while(<>) { chomp; next unless m/\d+\.\d+\.\d+\.\d+/; ($_ eq $s)?$n++:p; } p;
} foreach( map{ $fhs{$_}."\t".$_ } ipv4sort keys %fhs) { print; }


262     103.152.126.144
180     103.152.126.145
11      103.152.126.147
16      103.152.126.178
537     103.152.126.179
1       103.152.127.142
37      103.152.127.143
74      103.152.127.162
64      103.152.127.163
600     103.152.127.164
247     103.152.127.166
91      206.83.116.6
2       206.83.116.61
191     206.83.116.132
187     206.83.116.142
1       206.83.116.151
580     206.83.116.166
456     206.83.116.192
559     206.83.116.201
1784    206.83.116.202
1       206.83.116.210
36      206.83.116.218
193     206.83.116.228
97      206.83.116.232
660     206.83.116.240
3       206.83.116.253


PERL is AWK on heavy steroids..

and a very clever logic spectrum
you can even do ipv6 sorting instead by direct translation

Paul