in reply to Re^2: reaching into a perl script from a package
in thread reaching into a perl script from a package

Ok, so if I understand, you've got a script running, and within one of its used modules you wish to probe a completely different script to see if a particular function exists. Is that right?

Maybe you should search for that sub's name in the output from B::Xref.


Dave

  • Comment on Re^3: reaching into a perl script from a package

Replies are listed 'Best First'.
Re^4: reaching into a perl script from a package
by Brad.Walker (Sexton) on Oct 02, 2006 at 19:56 UTC
    That is correct..

    -brad w.

      Ok, so here is an example of grepping the output from B::Xref to find out if a particular file contains a sub.

      use strict; use warnings; my @xref = qx/perl -MO=Xref my_test_file.pl/; my $subname = "my_sub_name"; my @subs = grep { /(?:\&|Subroutine\s)$subname/ } @xref; print "$_\n" foreach @subs;

      Dave