zlacker

[parent] [thread] 14 comments
1. mono44+(OP)[view] [source] 2025-11-19 15:18:25
I think it is due to the fact that Perl has some confusing bits like those variable prefixes ($@%), the lack of function arguments (I know that this has changed recently), not really great error handling, etc and so people started using languages which seemed easier to use like Python.
replies(4): >>throww+x4 >>tasty_+kL >>12_thr+MM >>G3rn0t+gK2
2. throww+x4[view] [source] 2025-11-19 15:37:51
>>mono44+(OP)
The variable prefixes are just the tip of the iceberg. The real problem with those prefixes is that they, themselves, are context-dependent on attributes associated with the underlying data type at run time. So you can find yourself in a situation where the behavior of the syntax differs in ways that are difficult to control for during development.
replies(2): >>mono44+q7 >>zbentl+6z
◧◩
3. mono44+q7[view] [source] [discussion] 2025-11-19 15:52:59
>>throww+x4
Yep, there're all sorts of things like this in Perl. Its semantics has always been confusing to me.
◧◩
4. zbentl+6z[view] [source] [discussion] 2025-11-19 18:11:47
>>throww+x4
Strongly agree. A language which has something like “wantarray” as a first-class feature is semantically…unique, at best, probably more like “flawed by design”. All the oddness with typing and sigls descends from that.

Same for autovivification. Insane feature. Useful for some problems but causes many more.

Which is a shame, because perl5 semantics had some nice features too! But there’s only so much you can do with a structure whose foundation is so wacky.

replies(2): >>zahlma+JR >>karel-+z01
5. tasty_+kL[view] [source] 2025-11-19 18:59:12
>>mono44+(OP)
> the lack of function arguments (I know that this has changed recently)

Real arguments were added as of perl 5.20, which was in 2014.

replies(4): >>layer8+JM >>zahlma+ES >>poke64+C61 >>mkehrt+Kk1
◧◩
6. layer8+JM[view] [source] [discussion] 2025-11-19 19:04:48
>>tasty_+kL
That's "recently", relative to Perl's heyday.
7. 12_thr+MM[view] [source] 2025-11-19 19:04:58
>>mono44+(OP)
Yep. Perl the first language I ever used to professionally do something approximating "real programming" (as opposed to one-off scripting). And then I learned Python and never touched Perl again ... at least at the time, to my very inexperienced self, it felt like an improvement on every single axis.

In retrospect, probably 90% of my enthusiasm for python over perl was just "if you use python, you never have to think about variable sigils ever again." That and `string.split()`.

◧◩◪
8. zahlma+JR[view] [source] [discussion] 2025-11-19 19:31:10
>>zbentl+6z
I remember trying to use the new "reference" feature (when it was new), with "blessing" and so on and so forth, to try to create real data structures, and finding in some way or another that it was just not regular. I can't recall the details, but something along the lines of a feeling that the syntax worked differently for, say, the top level of a tree (or first index of a multidimensional array, etc.) vs the rest of the structure.
replies(1): >>darren+g81
◧◩
9. zahlma+ES[view] [source] [discussion] 2025-11-19 19:35:32
>>tasty_+kL
Yes, that's almost as old as some currently-hyped programming languages. But it's quite new compared to the natural behaviour of some developers (a fact that I used to find surprising and now just find disappointing).

Comparably: today, in the Python world, people are praising tools like uv because now they "don't have to understand virtual environments". And continuously since the introduction of PEP 668 three years ago, people have been grumbling about the expectation to leave "externally managed environments" alone. But uv still uses virtual environments; and `venv` has been in the standard library since 2012, and the third-party `virtualenv` that it's based on has been available since 2007.

◧◩◪
10. karel-+z01[view] [source] [discussion] 2025-11-19 20:13:08
>>zbentl+6z
You unlocked hidden memories within me.

I never understood why Perl has all these crazy features. It feels like someone going "hah it would be funny if it worked like this..." but actually really implementing it.

People always said "it's because Larry Wall is a linguist!" as if it explains anything!

You always go from "this is neat" to "...but why" quickly with perl.

◧◩
11. poke64+C61[view] [source] [discussion] 2025-11-19 20:45:04
>>tasty_+kL
As an experimental feature, with no guarantees it would remain in the language. It wasn't marked a stable feature until v5.36 (2022).
◧◩◪◨
12. darren+g81[view] [source] [discussion] 2025-11-19 20:52:03
>>zahlma+JR
In the main, the sigil refers to the type of the eventual value, regardless of what contains it. The tl;dr is that you mostly use `$` unless you're wanting more than one value, or to dereference (when you use the sigil for the type of reference). Some examples:

    @array = ("a", "b", "c", "d"); # @array contains scalars
    $array[0];                     # use `$` for a single element
    @array[0..2];                  # use `@` for an array slice
    @array = ( [1..5], [6..10] );  # @array now contains array references
    $array[0];                     # use `$` still because references are scalars
    $array[0][1];                  # still use `$` even when going multidimensional
    @{ $array[0] };                # use `@` to dereference an array ref to array
    %hash = ( a => "b", c => "d"); # % for hash of key/value pairs
    $hash{a};                      # `$` because you're getting a single scalar
    @hash{"a","c"};                # `@` because you're getting an array of values
Where things become a bit less regular is the difference between reference and non-reference for hashes and arrays when they are top level. At the top level, you need a `->` but that becomes optional at levels below (because at levels below, they have to be references).

    $arrayref = [1,1,2,3,5];       # `$` because we're creating an array reference
    $arrayref->[0];                # `->` because top level
    $arrayref = [ [ 1 ], [ 2 ] ];  # arrayref of arrayrefs
    $arrayref->[0][0];             # no second `->`
    $arrayref->[0]->[0];           # ... but you can use it if you want!
And then there's stuff like getting a slice out of an arrayref

    $arrayref = [1,1,2,3,5];
    $arrayref->@[0..3]; # oh dear. get a real array with an `@` but not at the start!
So... yeah.
replies(1): >>zahlma+vj1
◧◩◪◨⬒
13. zahlma+vj1[view] [source] [discussion] 2025-11-19 21:43:05
>>darren+g81
> Where things become a bit less regular is the difference between reference and non-reference for hashes and arrays when they are top level. At the top level, you need a `->` but that becomes optional at levels below

Yes, that's probably what I was remembering. Thanks for the exposition.

◧◩
14. mkehrt+Kk1[view] [source] [discussion] 2025-11-19 21:49:24
>>tasty_+kL
Sure, but perl was already dying by like 2005.
15. G3rn0t+gK2[view] [source] 2025-11-20 10:28:28
>>mono44+(OP)
> bits like those variable prefixes ($@%)

Perl originated from shell programming and inherited some of its patterns. If you ever looked at a bash script using arrays you will immediately recognize "@" to access the array as a whole and the switch to the "$" sigil to access a single element from that array. Perl was designed to make it easy for shell script writers to pick it up.

[go to top]