in reply to Try::Tiny complaining catch must be block or sub {} (not reference constructor)

I agree with AnomalousMonk that we'd need to see a short piece of example code that reproduces the issue, because I haven't been able to reproduce it myself, and I think it's a slightly strange issue.

Update: See Re: Try::Tiny complaining catch must be block or sub {} (not reference constructor).

must be block or sub {} (not reference constructor)

That sounds like this (from map), although as I said I'm not sure what's triggering it in this case:

{ starts both hash references and blocks, so map { ... could be either the start of map BLOCK LIST or map EXPR, LIST. Because Perl doesn't look ahead for the closing } it has to take a guess at which it's dealing with based on what it finds just after the {. Usually it gets it right, but if it doesn't it won't realize something is wrong until it gets to the } and encounters the missing (or unexpected) comma. The syntax error will be reported close to the }, but you'll need to change something near the { such as using a unary + or semicolon to give Perl some help:
my %hash = map { "\L$_" => 1 } @array # perl guesses EXPR. wrong my %hash = map { +"\L$_" => 1 } @array # perl guesses BLOCK. right my %hash = map {; "\L$_" => 1 } @array # this also works my %hash = map { ("\L$_" => 1) } @array # as does this my %hash = map { lc($_) => 1 } @array # and this.
  • Comment on Re: Try::Tiny complaining catch must be block or sub {} (not reference constructor) (updated)
  • Select or Download Code