News for hackers. Stuff that matters.
Re:The reports of Perl’s death have been greatly exaggerated by petre on Thursday October 21, 2021 @10:04AM (#28944556)
Well, that was inspired by sed. I have to do a test in Ruby too see how fast regexos are, being spoiled by Perl usage and all. What I don't like is this:

  my $a = 'Perl';
  my $b = $a;
  $b =~ s/pe/ea/i;
Why not do something to $a and obtain $b, just like js does with Array.map. Why the need to copy $a into to $b and then replace? Much more ellegant in Ruby:

  a = 'Ruby'
  b = a.gsub(/ru/i, 'mo')
Re:The reports of Perl’s death have been greatly exaggerated by chefandy on Thursday October 21, 2021 @11:22PM (#28953395)
oh— for regex performance Perl blows Swift, Java, Python, Ruby, Go, and C++ out of the water. For simple string manipulation— substring replacement, string reversal, etc. it's never the worst but never the best. Scroll down to the bottom of this paper where they test actual regexes though and the difference is pretty stunning.

http://jultika.oulu.fi/files/nbnfioulu-202001201035.pdf

Re:The reports of Perl’s death have been greatly exaggerated by chromatic on Thursday October 21, 2021 @03:03PM (#28949394)
No need to copy and then replace:

  my $a =  'Perl';
  my $b =~ s/pe/ea/ir;
Re:The reports of Perl’s death have been greatly exaggerated by petre on Friday October 22, 2021 @02:11AM (#28954160)
Doesn't work. You don't assign anything to $b, so it's undef:

  % perl -MData::Dumper=Dumper -e 'my $a = 'Perl'; my $b =~ s/pe/ea/ir; print Dumper $b;'
  $VAR1 = undef;
You probably mean:

  my $a = 'Perl';
  my $b = $a =~ s/pe/ea/ir;
Anyway, thank you for the /r modifier, it didn't know what it did, since there's no example in perlre(1).
Re:The reports of Perl’s death have been greatly exaggerated by chromatic on Friday October 22, 2021 @01:55PM (#28960363)
You're right, that's exactly what I meant!

I'm surprised there's no example in perlre(1); perhaps I can get that corrected.