in reply to understanding curly braces surrounding an array
The first syntax: $#{@alarms} isn't much good for anything beyond obfuscation, and shouldn't pass strictures. I don't know if it worked in some way that it shouldn't have back when Perl 5.8.8 was current, but here's what I think it is, deobfuscated nowadays:
@alarms in scalar context will yield the number of elements in @array. Let's say you have one element. So it returns the number 1.
$#{....} will attempt to either dereference '....', or if it's not a reference, use '....' as a symbol. In this particular example, '....' happens to be the string '1'. '1' comes from the number of elements in @array.
Using '1' as a symbol, and placing a $# sigil in front of it, you now have a symbolic reference. You're asking Perl what the highest index is in the array named @1. I can't think of any reason that there would be an array named @1, but it probably doesn't have any practical relationship to @array, so the code in your first example is useless.
The usage is far enough off the beaten path that I could be wrong about how it's parsed, but that seems reasonable to me at the moment.
Dave
|
|---|