this post was submitted on 10 Sep 2023
65 points (93.3% liked)

Technology

59669 readers
3549 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


founded 1 year ago
MODERATORS
 

hi, i was interested if perl is still relevant in this day and age. Perl has been on the decline for a very long time now. Perl 6 (now named 'raku) not being backwards compatible with perl 5 code made the already small perl community even smaller by splitting it in half. A good example is lisp with it's thousands of different dialects.

Is it still worth using or is it bound to legacy software forever? Like cobol.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

You mean the fact that you can have a hash called %foo, an array called @foo and a scalar called $foo all at the same time?

Yes, exactly. Those definitions aren't clashing, so they must have separate namespaces.

it’s pretty easy to just not do that…

I wouldn't do that either, but my colleage apparently did. So far I'm having a harder time reading perl than writing it.

[–] [email protected] 1 points 1 year ago

The way it works is that there's a symbol table entry for "foo" which has a slot for a hash, scalar, array, glob, etc.

That leads to some super weird behaviour like, for example, if I declare a scalar, hash and array as "x":

$x = "sy";
%x = (foo => "mb");
@x = ("ol", "s!");

You can access them all independently as you're aware:

say "x: ", $x, $x{foo}, @x; # Outputs:  x: symbols!

But what's really going to bake your noodle is I can assign the "x" symbol to something else like this:

*z = *x;

..and then the same thing works with z:

say "z: ", $z, $z{foo}, @z; # Outputs:  z: symbols!

Oneliner if you want to try it:

perl -E '$x = "sy"; %x = (foo => "mb"); @x = ("ol", "s!"); say "x: ", $x, $x{foo}, @x; *z = *x; say "z: ", $z, $z{foo}, @z;'

Congratulations! You now know more about one of Perl's really weird internals than I'd wager most Perl programmers (I have literally never used any of the above for anything actually productive!)