Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^6: Introsepcting the current Perl file via DATA, even w/o DATA? (perl5db.pl)

by Mr. Muskrat (Canon)
on Feb 05, 2016 at 16:37 UTC ( [id://1154489]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Introsepcting the current Perl file via DATA, even w/o DATA? (perl5db.pl)
in thread Introspecting the current Perl file via DATA, even w/o DATA?

I found this interesting so I played with it briefly...

# main.pl my @source = @{ $main::{ '_<' . __FILE__ } }; shift @source; # get rid of sub DB::DB{}; print for @source;
and
PERL5DB="sub DB::DB{}" perl -d main.pl

Output:

my @source = @{ $main::{ '_<' . __FILE__ } }; shift @source; # get rid of sub DB::DB{}; print for @source;

Update: I had found @{$main::{'_<'.$filename}} yesterday but didn't have time to play with it.

Update 2: Added shift.

Replies are listed 'Best First'.
Re^7: Introspecting the current Perl file via DATA, even w/o DATA? (perl5db.pl)
by LanX (Saint) on Feb 05, 2016 at 17:05 UTC
    > Added shift.

    as a side note: line numbers start with 1, so changing the content of the 0th element may be the better strategy. ( Otherwise looking up a line will include a cumbersome -1 operation.)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2024-04-23 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found