perl caller seems to be giving the "wrong" line around definition of coderef. I'd expect caller to flag line 8, but it's flagging line 12.
The deparser seems to give some quirky output, too.
Can anyone help me figure out what's going on here?
Thanks
> perl -v | head -n2
This is perl 5, version 16, subversion 2 (v5.16.2) built for x86_64-li
+nux
> cat -n program.pl
1 sub foo {
2 print join(", ", caller(0)) . "\n";
3 }
4
5 my %hash = (
6 A => 'foo',
7 B => {
8 C => foo(),
9 },
10 D => 'foo',
11 E => sub { return 1; },
12 F => 'foo',
13 G => 'foo',
14 );
15
16 my $foo = 'bar';
> perl program.pl
main, program.pl, 12, main::foo, 1, 1, , , 0, ,
> perl -MO=Deparse,-p,-l program.pl
#line 3 "program.pl"
sub foo {
#line 2 "program.pl"
print((join(', ', caller(0)) . "\n"));
}
#line 12 "program.pl"
(my(%hash) = ('A', 'foo', 'B', {'C', foo()}, 'D', 'foo', 'E', sub {
#line 11 "program.pl"
(return 1);
}
, 'F', 'foo', 'G', 'foo'));
#line 16 "program.pl"
(my $foo = 'bar');
program.pl syntax OK
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.