eXile has asked for the wisdom of the Perl Monks concerning the following question:
This will dump the symbol table after line 5 in the script and after line 7 in the script. This far I've come up with this:symdump script1.pl 5 7
This doesn't print any symbols for my testscripts. If I change the rnew('<longpackagename>') to rnew('main') it will print all symbols including the symbols used in Devel::Symdump. Tried using the diff method in Devel::Symdump but that does only show a diff (duh), so any packages used in my script AND in Devel::Symdump will not show up. What I could do is make 2 Symdump-objects, one of the eval-ed code, one of Devel::Symdump itself, and compare their as_string output manually (it's sorted already), but that doesn't help me understand why the above code doesn't work.#!/usr/bin/perl use strict; use warnings; use Devel::Symdump; $| = 1; my $code; my $program=shift @ARGV; die ("usage: $0 <programname> <linenr.> [<linenr.>...]\n") unless ($pr +ogram); open (PRG, $program) or die "cant open '$program'\n"; my $symdumpcode = " \$main::obj=Devel::Symdump->rnew('ThisIsAnotherPackageAndMostLikelyWil +lNeverCollideWithAnyOtherNamespace'); print \$main::obj->as_string(); "; my $idx=0; foreach my $arg (sort {$a <=> $b} @ARGV) { while (<PRG>) { $idx++; $code .= $_; last if ($arg == $idx and $code .= $symdumpcode); } } close PRG; eval "package ThisIsAnotherPackageAndMostLikelyWillNeverCollideWithAny +OtherNamespace; $code"; print $@ if ($@);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Devel::Symdump without Devel::Symdump interference
by broquaint (Abbot) on Apr 19, 2004 at 18:45 UTC | |
by eXile (Priest) on Apr 20, 2004 at 01:51 UTC | |
by broquaint (Abbot) on Apr 20, 2004 at 01:57 UTC |