Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Robert Price

[snipped my numbers formated as 0207 XX]

>Shouldn't these numbers be formatted 020 7XXX

Sh, it's designed to try to fool the sales bunnies.

Rob




Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Mark Fowler

> Yup, that's right. So to get it to only have the one call, change your
> "use" to a require and put it in the BEGIN block.



use fred;

Will also call fred->import(), so you might want to emulate that too.





> --
> Robert Price - Technical Manager - EMAP Digital Travel  | Tel: 0207 3092711
> Priory Court, 30-32 Farringdon Lane, London, EC1R 3AW   | Fax: 0207 3092718
> 

Shouldn't these numbers be formatted 020 7XXX

Later.

Mark.



-- 
print "\n",map{my$a="\n"if(length$_>6);' 'x(36-length($_)/2)."$_\n$a"} (
   Name  => 'Mark Fowler',Title => 'Technology Developer'  ,
   Firm  => 'Profero Ltd',Web   => 'http://www.profero.com/'   ,
   Email => '[EMAIL PROTECTED]',   Phone => '+44 (0) 20 7700 9960'  )









Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Robert Price

At 03:03 PM 3/8/01 +, you wrote:
>Oh, actually do you mean it is the same at:
>
>pageage LTest;
>
>BEGIN {require Test2}
>BEGIN { warn "." }
>
>print "Here\n"
>
>1;

[snip]

Yup, that's right. So to get it to only have the one call, change your
"use" to a require and put it in the BEGIN block.

Rob

--
Robert Price - Technical Manager - EMAP Digital Travel  | Tel: 0207 3092711
Priory Court, 30-32 Farringdon Lane, London, EC1R 3AW   | Fax: 0207 3092718



Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Philip Newton

Leo Lapworth wrote:
> BEGIN {

You forgot here: warn "In A.D. 2101\n";

> warn "Test is beginning\n";
> }
> 
> print "Here\n";

And this should be 'print "What happen?\n";'.

Cheers,
Phi "SCNR" lip
-- 
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.



Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Leo Lapworth

Oh, actually do you mean it is the same at:

pageage LTest;

BEGIN {require Test2}
BEGIN { warn "." }

print "Here\n"

1;

Ok, that kind'a make sence..

Cheers

Leo <- who is slowly getting there.


On Thu, Mar 08, 2001 at 02:52:48PM +, Leo Lapworth wrote:
> On Thu, Mar 08, 2001 at 02:59:27PM +, Robert Price wrote:
> > I think the answer is that both the modules where the BEGINS are called
> > twice have "use" in them. "use" means "BEGIN {require Module}", so BEGIN is
> > being called once when the module is entered, and once when it is used. 
> > 
> > Rob
> > 
> - SNIP -
> 
> Fraid not.. tried moving the use out of the BEGIN before and it
> made no difference:
> 
> package LTest;
> 
> use Test2;
> 
> BEGIN {
> warn "Test is beginning\n";
> }
> 
> print "Here\n";
> 
> 1;
> 
> 
> Thanks
> 
> Leo
> 



Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Robert Price

At 02:52 PM 3/8/01 +, you wrote:
>On Thu, Mar 08, 2001 at 02:59:27PM +, Robert Price wrote:
>> I think the answer is that both the modules where the BEGINS are called
>> twice have "use" in them. "use" means "BEGIN {require Module}", so BEGIN is
>> being called once when the module is entered, and once when it is used. 
>> 
>> Rob
>> 
>- SNIP -
>
>Fraid not.. tried moving the use out of the BEGIN before and it
>made no difference:
>
>package LTest;
>
>use Test2;
>
>BEGIN {
>warn "Test is beginning\n";
>}

[snip]

But you are still calling "use", and as I said earlier, that means there
are still 2 BEGIN blocks, so both are being called. Test2 only has the one
BEGIN call because it doesn't try to use. 

For example, your code is roughly the same as...

package LTest;

BEGIN {require Test2};

BEGIN {
warn "Test is beginning\n";
}


So you can see there are two BEGIN blocks that are being called.

Or am I talking out of my arse? :-)


Rob

--
Robert Price - Technical Manager - EMAP Digital Travel  | Tel: 0207 3092711
Priory Court, 30-32 Farringdon Lane, London, EC1R 3AW   | Fax: 0207 3092718



Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Leo Lapworth

On Thu, Mar 08, 2001 at 02:59:27PM +, Robert Price wrote:
> I think the answer is that both the modules where the BEGINS are called
> twice have "use" in them. "use" means "BEGIN {require Module}", so BEGIN is
> being called once when the module is entered, and once when it is used. 
> 
> Rob
> 
- SNIP -

Fraid not.. tried moving the use out of the BEGIN before and it
made no difference:

package LTest;

use Test2;

BEGIN {
warn "Test is beginning\n";
}

print "Here\n";

1;


Thanks

Leo



Re: Am I going nutts ? - read before answering!

2001-03-08 Thread Robert Price

I think the answer is that both the modules where the BEGINS are called
twice have "use" in them. "use" means "BEGIN {require Module}", so BEGIN is
being called once when the module is entered, and once when it is used. 

Rob


At 02:39 PM 3/8/01 +, Leo wrote:
>Hi folks, got an odd one for you:
>
>Why is Dprof saying my LTest::BEGIN and mail::BEGIN
>are running twice ?
>
>%Time ExclSec CumulS #Calls sec/call Csec/c  Name
> 33.4   0.010  0.010  2   0.0050 0.0050  main::BEGIN<- ?
> 0.00   0.000 -0.000  1   0.  -  strict::import
> 0.00   0.000 -0.000  1   0.  -  strict::bits
> 0.00   0.000 -0.000  2   0.  -  LTest::BEGIN   <- ?
> 0.00   0.000 -0.000  1   0.  -  Test2::BEGIN
>
>I've actually got this problem but magnified in a larger
>project which I'm trying to find a memory leak in.. I don't now
>if this is related (BEGIN being run 4 to 17 times! in different
>packages). 
>
>Is this my code, my not understanding Dprof or something else ?
>
>perl -v
>This is perl, v5.6.0 built for i386-linux
>
>test.pl
>---
>#!/usr/bin/perl
>use strict;
>use LTest;
>
>package LTest;
>
>BEGIN {
>   use Test2;
>warn "Test is beginning\n";
>}
>
>print "Here\n";
>
>1;
>
>package Test2;
>
>BEGIN {
>warn "Test2 is beginning\n";
>}
>
>1;
>
>
>Oh, running this code gives:
>
>>./test.pl
>Test2 is beginning
>Test is beginning
>Here
>
>Making is even wierder! As 'Test is..' only
>prints once.
>
>Any help is much appreciated.
>
>Cheers
>
>Leo
>
>

--
Robert Price - Technical Manager - EMAP Digital Travel  | Tel: 0207 3092711
Priory Court, 30-32 Farringdon Lane, London, EC1R 3AW   | Fax: 0207 3092718



Am I going nutts ? - read before answering!

2001-03-08 Thread Leo Lapworth

Hi folks, got an odd one for you:

Why is Dprof saying my LTest::BEGIN and mail::BEGIN
are running twice ?

%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 33.4   0.010  0.010  2   0.0050 0.0050  main::BEGIN<- ?
 0.00   0.000 -0.000  1   0.  -  strict::import
 0.00   0.000 -0.000  1   0.  -  strict::bits
 0.00   0.000 -0.000  2   0.  -  LTest::BEGIN   <- ?
 0.00   0.000 -0.000  1   0.  -  Test2::BEGIN

I've actually got this problem but magnified in a larger
project which I'm trying to find a memory leak in.. I don't now
if this is related (BEGIN being run 4 to 17 times! in different
packages). 

Is this my code, my not understanding Dprof or something else ?


perl -v
This is perl, v5.6.0 built for i386-linux

test.pl
---
#!/usr/bin/perl
use strict;
use LTest;

package LTest;

BEGIN {
use Test2;
warn "Test is beginning\n";
}

print "Here\n";

1;

package Test2;

BEGIN {
warn "Test2 is beginning\n";
}

1;


Oh, running this code gives:

>./test.pl
Test2 is beginning
Test is beginning
Here

Making is even wierder! As 'Test is..' only
prints once.

Any help is much appreciated.

Cheers

Leo