how to trace a subroutine?

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default how to trace a subroutine?

    I have a subroutine "foo" in a file "my.pl".
    I invoke it by:
    require "my.pl";
    &foo;

    This has worked fine for a while. Now I try to
    make changes in foo by updating the code in
    my.pl, and the changes are not taking place?
    &foo just keeps doing the old code. What I
    suspect is that there is a "foo" subroutine
    somewhere else in the include path that had
    the old code, but I can't find it. Is there a
    way to trace where perl got the foo subroutine?
    Any other suggestions on tracking this down?

    TIA, Peter
    Wild Pete Guest

  2. Similar Questions and Discussions

    1. Who called subroutine.
      Hi, a basic question how do I know who called my subroutine ? It could be main, it could be another subroutine. Is setting a return value on a...
    2. undefined subroutine
      I'm doing a php to pl migration and having a little trouble. Help appreciated! Undefined subroutine &main::fopen called at...
    3. subroutine problem
      Hi all, I have recently started to learn perl. After reading Randal Schwartz’s Learning perl, I decided to give my first program a whirl. Upon...
    4. Subroutine as a new Task
      Hello, how can I start a soubroutine as a new task. The main script should run on until the end is reached. But the subroutine should run in...
    5. using subroutine from another file
      Let's say thatI wroute some code long time ago: code1.pl. In the file there is this subroutine1(); now I am writting another code code2.pl, and...
  3. #2

    Default Re: how to trace a subroutine?

    Wild Pete wrote:
    > I have a subroutine "foo" in a file "my.pl".
    > I invoke it by:
    > require "my.pl";
    > &foo;
    >
    > This has worked fine for a while. Now I try to
    > make changes in foo by updating the code in
    > my.pl, and the changes are not taking place?
    > &foo just keeps doing the old code. What I
    > suspect is that there is a "foo" subroutine
    > somewhere else in the include path that had
    > the old code, but I can't find it. Is there a
    > way to trace where perl got the foo subroutine?
    > Any other suggestions on tracking this down?
    >
    it's bad form, but why not give a full path to my.pl?
    that way you know which one it is loading.

    or from perldoc perlrun
    ([url]http://www.perldoc.com/perl5.8.0/pod/perlrun.html[/url])

    trace each line of your program as it runs:


    # Bourne shell syntax
    $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program
    > TIA, Peter
    Terrence Brannon Guest

  4. #3

    Default Re: how to trace a subroutine?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    [email]peter@for-wild.org[/email] (Wild Pete) wrote in
    news:e4b0fcf8.0312010715.5e507c9d@posting.google.c om:
    > I have a subroutine "foo" in a file "my.pl".
    > I invoke it by:
    > require "my.pl";
    > &foo;
    >
    > This has worked fine for a while. Now I try to
    > make changes in foo by updating the code in
    > my.pl, and the changes are not taking place?
    > &foo just keeps doing the old code. What I
    > suspect is that there is a "foo" subroutine
    > somewhere else in the include path that had
    > the old code, but I can't find it. Is there a
    > way to trace where perl got the foo subroutine?
    > Any other suggestions on tracking this down?
    Are you modifying my.pl while the main script is still running? Because
    'require' won't load the file a second time once it has been loaded
    (unless you play some really ugly games with perl's loading mechanism).

    Also, FYI, it's generally bad style to invoke a subroutine with an
    ampersand unless you know why you are doing so.

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP8v1/2PeouIeTNHoEQKSAACeJkEuoNAMdtaes+Yk90EsJZr1h6oAoN2 p
    zc0KbqDCEWuh430e+FCe+Jli
    =5G76
    -----END PGP SIGNATURE-----
    Eric J. Roode Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139