chorankates has asked for the wisdom of the Perl Monks concerning the following question:
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)"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variable based #line directives?
by Corion (Patriarch) on Aug 20, 2011 at 20:46 UTC | |
by chorankates (Novice) on Aug 20, 2011 at 22:04 UTC | |
by Corion (Patriarch) on Aug 21, 2011 at 07:35 UTC | |
by choroba (Cardinal) on Aug 23, 2011 at 09:45 UTC | |
|
Re: variable based #line directives?
by chromatic (Archbishop) on Aug 21, 2011 at 08:24 UTC | |
by chorankates (Novice) on Aug 22, 2011 at 16:28 UTC | |
|
Re: variable based #line directives?
by TomDLux (Vicar) on Aug 20, 2011 at 23:00 UTC | |
by chorankates (Novice) on Aug 21, 2011 at 03:38 UTC |