develooper Front page | perl.perl5.porters | Postings from November 2014

[perl #123236] B::Deparse and #line 1 somefile

Thread Next
Father Chrysostomos
November 18, 2014 02:30
[perl #123236] B::Deparse and #line 1 somefile
Message ID:
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #123236]
# in the subject line of all future correspondence about this issue. 
# <URL: >

Ideally, one should be able to take the output of perl -MO=Deparse and feed it to perl, and it should run the same way as  Or at least I think that is the ideal.

But if the main program has #line directives that change the file name, then some sub definitions will be omitted, unless we use the -f option to include them:

$ perl -MO=Deparse -e 'sub foo{}' -e '#line 1 thwirp' -e 'sub bar{}'
sub foo {
-e syntax OK
$ perl -MO=Deparse,-fthwirp -e 'sub foo{}' -e '#line 1 thwirp' -e 'sub bar{}'
sub foo {
sub bar {
-e syntax OK

This means that, to deparse a whole program, you have to scan it first for #line directives with file names and pass them to B::Deparse’s -f option.

The documentation for the -f option includes:

    (Most of the time you don't want to
    use it at all.) You can also use this option to include subs which are
    defined in the scope of a B<#line> directive with two parameters.

The last sentence seems to imply that the current behaviour is intentional, but it hardly seems ideal.  The parenthesised sentence before it seems to imply that my complaint is valid.

It is not hard to detect which subs are declared inside the main program, regardless of which file names are associated with them.

Is this something I should do?


Father Chrysostomos

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About