$ENV{PERL_DPROF_OUT_FILE_NAME} = "foo${$}.out"; is how to change that. I've never tried profiling over a fork, though.

It looks as if the child will have to be started with that environment variable localized.

Update: I have tried it now, couldn't work it without going through the shell,
file prof.pl:

#!/usr/bin/perl -d:DProf { local $ENV{PERL_DPROF_OUT_FILE_NAME} = "foo.out"; my $cpid = open my $foo, '|-', '/usr/bin/perl -d:DProf profc.pl' o +r die $!; } print 'In Parent', $/ or die $!; sleep 10;
file profc.pl:
#!/usr/bin/perl print 'In Child',$/ or die $!; sleep 10;
$ ./prof.pl
In Child
In Parent
$ ls *.out
foo.out tmon.out

After Compline,
Zaxo


In reply to Re: Re: Profiling forking code? by Zaxo
in thread Profiling forking code? by Jeppe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.