i'm trying to use variables in #line directives so that i can pass the proper line/file on. essentially, i've written a wrapper to Test::More, and instead of seeing which line/file the tests fail on, it displays the line in my wrapper library.
short version of what i'm trying:test.pm#!/usr/bin/perl -w use strict; use warnings; use lib '.'; use test; my $l = 200; my $ld = 'foo'; #line $l $ld ; test::test(); exit;
i'm seeing:package test; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(); sub test { my @caller = caller(); print "@caller\n"; print "DBGZ" if 0; } 1;
i want to see:$ perl test.pl main test.pl 13
$ perl test.pl main foo 200
the llama book says: Technically, it matches the pattern /^#\s*line\s+(\d+)\s*(?:\s"(^"+)")?\s*$/, with $1 providing the line number for the next line, and $2 providing the optional filename specified within quotes. (A null filename leaves __FILE__ unchanged.)
making me think this is not possible, but then i see AutoSplit.pm:
can anyone point me in the right direction to allow variables in #line directives? or at least confirm that it is not possible..#line $lineno "$filename (autosplit into $path)"
In reply to variable based #line directives? by chorankates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |