http://www.perlmonks.org?node_id=1224342

roboticus has asked for the wisdom of the Perl Monks concerning the following question:

Thanks, guys! That was a quick resolution. Indirect Object syntax was what tripped me up. As haukex suggests, I'll have to start using the Yadda, Yadda operator ... to ensure that I don't miss that in the future.

Using that operator and a comment, I can either let the program run and execute and die only if I reach unfinished code:

sub find_symbol { ... # got to here today! (20180520) }
$ perl xyzzy.pl Foo! Unimplemented at xyzzy.pl line 13.

Or if I'd rather have the program just fail without running, I can prefix my original comment with the operator (so long as I don't use a semicolon as the first character in my comment:

sub find_symbol { ... got to here today! (20180520) }
$ perl xyzzy.pl syntax error at xyzzy.pl line 12, near "... got to " Execution of xyzzy.pl aborted due to compilation errors.

Really, though, not one Monty Python reference? 8^)

Original post follows:


Hello, gang:

When I write experimental bits of code and don't get a chance to finish, I'll frequently mark my position with a few words and no comment marker with the intent that if I run the program, perl will tell me that bit(s) of my code are unfinished, and let me know where the unfinished bits are. This morning I decided to adapt a working program I've been using all week to add some new functionality, and when I looked at the code, I saw this bit:

sub find_symbol { got to here today! (20180520) }

What the heck? The code is working, but that subroutine just can't be right. So I looked over the program--It doesn't look like the code is commented out anywhere (I normally use "=h1 foo" and "=cut" to comment out blocks of code I don't want to use). I ran:

$ perl -c LTSpice_to_graph.pl LTSpice_to_graph.pl syntax OK

OK, then, *something* has to be masking this syntax error, right? So I copied the code to xyzzy.pl and started removing chunk after chunk, eventually coming up with:

$ cat xyzzy.pl #!env perl use strict; use warnings; find_symbol(); sub find_symbol { got to here today } $ perl -c xyzzy.pl xyzzy.pl syntax OK $ perl -MO=Concise xyzzy.pl 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 5 xyzzy.pl:5) v:*,&,{,x*,x&,x$,$ ->3 5 <1> entersub[t2] vKS/TARG,STRICT ->6 - <1> ex-list K ->5 3 <0> pushmark s ->4 - <1> ex-rv2cv sK/STRICT,1 ->- 4 <#> gv[*find_symbol] s/EARLYCV ->5 - <;> ex-nextstate(main 7 xyzzy.pl:10) v:*,&,{,x*,x&,x$,$ ->6 xyzzy.pl syntax OK

So consider me baffled, I don't know what's going on here. Can anyone tell me what I'm not seeing?

For the record:

$ perl -version This is perl 5, version 26, subversion 2 (v5.26.2) built for x86_64-cy +gwin-threads-multi (with 7 registered patches, see perl -V for more detail)

Interesting ... one more bit of information before I hit the preview button. I changed the contents of the subroutine to:

sub find_symbol { I got to here today }

and now I get what I expected to see:

$ perl -c xyzzy.pl Bareword "today" not allowed while "strict subs" in use at xyzzy.pl li +ne 8. xyzzy.pl had compilation errors.

Does anyone know what's happening here? My only (ill-informed) guess would be something to do with parsing the GOTO statement.

...roboticus

When your only tool is a hammer, all problems look like your thumb.