Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

B::Deparse (with comments)

by fionbarr (Friar)
on Feb 16, 2015 at 19:54 UTC ( [id://1116922]=perlquestion: print w/replies, xml ) Need Help??

fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

Is there a flag for B::Deparse that retains comments? Or another method of parsing Perl code that keeps comments?

Replies are listed 'Best First'.
Re: B::Deparse (with comments)
by LanX (Saint) on Feb 16, 2015 at 20:43 UTC
    > Is there a flag for B::Deparse that retains comments?

    no¹, but -l will point you to the original source line

    -l Add '#line' declarations to the output based on the line and file +locations of the original code.

    for instance

    perl -MO=Deparse,-l tst_glob.pl #line 1 "tst_glob.pl" $\ = "\n"; #line 3 "tst_glob.pl" $n = 123; #line 5 "tst_glob.pl" $gr = \*n; ...

    so just write yourself a post processor script to reinclude the missing lines as comments or POD or here-docs or whatever.

    I recommend using Perl, it's good at text processing. ;-)

    Cheers Rolf

    PS: Je suis Charlie!

    ¹) IIRC does B::Concise have an option to include original code... (update: yes -src )

Re: B::Deparse (with comments)
by toolic (Bishop) on Feb 16, 2015 at 20:28 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1116922]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found