Syntax checking - or how to lose against a >

TL;DR

I wasted way too much time debugging a silly syntax error.

To make a long story short, here’s an equivalent of what I was writing:

my $foo => Some::Class->new;
say defined($foo) ? 'foo is defined' ! 'foo is NOT defined';

Easy to spot now that you know that there’s something fishy around, uh?

If you didn’t spot it already, there’s a stray > character that totally changes the meaning of the = sign immediately before, thwarting the assignment to $foo.

Result? $foo remains unassigned and undef.

I could only figure out this after writing a brand new line like the following, and putting it close to the original

my $bar =  Some::Class->new;
my $foo => Some::Class->new;

Of course now, with the right alignment and puntuation, the solution appears trivial. Now being the key concept.

Stay safe and keep both eyes open!


Comments? Octodon, , GitHub, Reddit, or drop me a line!