thanks to Paul I just learned about a Perl feature I never knew existed. I've seen code like this
#line 500 Foo.pm
in XS-generated C and the occasional Perl file before and just figured it was a way of keeping track of things for developers - a helpful comment. as it turns out, this little bit of code has special meaning to perl. observe.
$ cat line.pl
#!/usr/bin/perl
#line 500 Foo.pm
die "yikes";
$ perl line.pl
yikes at Foo.pm line 500.
while this is kinda cool, as it turns out it creates
some difficult to solve issues with
Devel::Cover
. so actually, I kinda loathe this feature at the moment as it is keeping me from being able to get nice coverage results for some code I am testing.
things that prohibit test coverage metrics--
C feature
rafael on 2004-06-28T15:51:56
#line 500 Foo.pm
is a standard C feature, so in XS-generated C code it's understood by the C preprocessor. (lex, yacc and other code generators make extensive use of this feature.)
A little-known fact is that perl actually understands this kind of comments as well.
Extracting tests
dws on 2004-06-28T18:57:22
#line 500 foo.pm
is really handy when you've extracted tests from several sources into one .t