Re: apache::registry + use strict curiosity

2001-04-26 Thread Ken Williams

Yes, exactly.  After the first run, $test got an entry in the symbol
table.  Not usually an issue in CGI perl. =)


[EMAIL PROTECTED] (Eric Kolve) wrote:
I found something a bit curious that I was wondering if someone could
explain. I have the following apache::registry script I called test.reg:

#!/usr/bin/perl
 
use strict;
if($test){
# do stuff
}
 
 
print qq|HTTP/1.1 200 OK\r\n|;
print HELLO WORLD\n\n;


I ran my server in single-user mode (httpd -X) and requested the page
which causes an internal server error because I didn't declare '$test'. 
I next commented out the three conditional lines:

#if($test){
# do stuff
#}

Then requested the page a second time, which executed just fine. I
uncommented those three lines and requested the page a third time, which
strangely enough actually works.  Registry stats pages to see if they
change and recompiles pages I believe.  So I am wondering why isn't an
exception raised on the third request about not declaring '$test'?  Did
the first request put '$test' in the symbol table?

  ------
  Ken Williams Last Bastion of Euclidity
  [EMAIL PROTECTED]The Math Forum



Re: apache::registry + use strict curiosity

2001-04-26 Thread newsreader


that's no apache::registry.  that's perl

there are big guns here who can answer
your questions but it am not one of them.


On Thu, Apr 26, 2001 at 02:25:17PM -0700, Eric Kolve wrote:
 I found something a bit curious that I was wondering if someone could
 explain. I have the following apache::registry script I called test.reg:
 
 #!/usr/bin/perl
  
 use strict;
 if($test){
 # do stuff
 }
  
  
 print qq|HTTP/1.1 200 OK\r\n|;
 print HELLO WORLD\n\n;
 
 
 I ran my server in single-user mode (httpd -X) and requested the page
 which causes an internal server error because I didn't declare '$test'. 
 I next commented out the three conditional lines:
 
 #if($test){
 # do stuff
 #}
 
 Then requested the page a second time, which executed just fine. I
 uncommented those three lines and requested the page a third time, which
 strangely enough actually works.  Registry stats pages to see if they
 change and recompiles pages I believe.  So I am wondering why isn't an
 exception raised on the third request about not declaring '$test'?  Did
 the first request put '$test' in the symbol table?
 
 thanks,
 
 --eric



Re: Apache::Registry() and strict

2000-11-13 Thread remco

On Sun, 12 Nov 2000, Stas Bekman wrote:

Hi,

  Please explain, the guide appears to recommend -w as a useful
  diagnostic technique (and the "Command Line Switches (-w, -T,
  etc)" section says -w works).

 The guide is correct. -w in the shebang line is equal to 'local $^W=1' for
 the file scope. and it does have an effect (for the file it's defined in).

Stas is right, I mixed up -w and -T:-(((
Sorry for bothering you guys...

Bye,
remco

/--\
| Remco Schaar |
| e-mail: [EMAIL PROTECTED]  |
\--/

South Park meets Linux:
- "Oh my God, they killed init!"
- "You bastards!"




Re: Apache::Registry() and strict

2000-11-12 Thread Stas Bekman

On Tue, 7 Nov 2000, Paul DuBois wrote:

 At 10:25 AM +0100 11/7/00, [EMAIL PROTECTED] wrote:
 On Tue, 7 Nov 2000, Ron Rademaker wrote:
 
 Hi,
 
   You would think so, however every doc I read (including the one you
   pointed out to me) told me that perl gives me a warning:
 
   Variable $foo will not stay shared at 
 
   I do use -w so I should get that warning, but I don't. The variable stays
   defined, but it doesn't have the value of the old variable, it just passes
   the defined($foo) test but the value has changed to an empty array (from a
   full array).
 
 -w has no effect, read the guide again and use PerlWarn On :-)
 
 Please explain, the guide appears to recommend -w as a useful
 diagnostic technique (and the "Command Line Switches (-w, -T,
 etc)" section says -w works).

The guide is correct. -w in the shebang line is equal to 'local $^W=1' for
the file scope. and it does have an effect (for the file it's defined in).

 
 
 Bye,
 remco
 
 /--\
 | Remco Schaar |
 | e-mail: [EMAIL PROTECTED]  |
 \--/
 
  South Park meets Linux:
  - "Oh my God, they killed init!"
  - "You bastards!"
 
 



_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com   perl.org   apache.org





Re: Apache::Registry() and strict

2000-11-07 Thread ed phillips

Ron,

This is a greivous FAQ.  Please read the guide at
http://perl.apache.org/guide

You'll find much more than this question answered.

Ed



Ron Rademaker wrote:

 Hello,

 I'm just starting with mod_perl and I'm using Apache::Registry(). The
 second line after #!/usr/bin/perl -w is use strict;
 But somehow variables I use in the script are still defined if I execute
 the script again, in one of the script I said undef $foo at the
 end, but I don't think this is the way it should be done, but it did work.
 Anyone knows what could be causing this??

 Ron Rademaker

 PS. Please CC to me because I'm not subscribed to this mailinglist




Re: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

You would think so, however every doc I read (including the one you
pointed out to me) told me that perl gives me a warning:

Variable $foo will not stay shared at 

I do use -w so I should get that warning, but I don't. The variable stays
defined, but it doesn't have the value of the old variable, it just passes
the defined($foo) test but the value has changed to an empty array (from a
full array).

Ron

On Mon, 6 Nov 2000, ed phillips wrote:

 Ron,
 
 This is a greivous FAQ.  Please read the guide at
 http://perl.apache.org/guide
 
 You'll find much more than this question answered.
 
 Ed
 
 
 
 Ron Rademaker wrote:
 
  Hello,
 
  I'm just starting with mod_perl and I'm using Apache::Registry(). The
  second line after #!/usr/bin/perl -w is use strict;
  But somehow variables I use in the script are still defined if I execute
  the script again, in one of the script I said undef $foo at the
  end, but I don't think this is the way it should be done, but it did work.
  Anyone knows what could be causing this??
 
  Ron Rademaker
 
  PS. Please CC to me because I'm not subscribed to this mailinglist
 




Re: Apache::Registry() and strict

2000-11-07 Thread remco

On Tue, 7 Nov 2000, Ron Rademaker wrote:

Hi,

 You would think so, however every doc I read (including the one you
 pointed out to me) told me that perl gives me a warning:
 
 Variable $foo will not stay shared at 
 
 I do use -w so I should get that warning, but I don't. The variable stays
 defined, but it doesn't have the value of the old variable, it just passes
 the defined($foo) test but the value has changed to an empty array (from a
 full array).

-w has no effect, read the guide again and use PerlWarn On :-)

Bye,
remco

/--\
| Remco Schaar |
| e-mail: [EMAIL PROTECTED]  |
\--/

South Park meets Linux:
- "Oh my God, they killed init!"
- "You bastards!"




Re: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

Just tried, it didn't give me any useful information, I always got any
other warning without PerlWarn on, so I don't think it made any
difference. Anyway, even with PerlWarn on, the error.log still shows
exactly the same output, everything goes well for a while, but then
suddenly my defined($foo) check succeeds where it should have failed, but
the old value is gone.

Ron

On Tue, 7 Nov 2000 [EMAIL PROTECTED] wrote:

 On Tue, 7 Nov 2000, Ron Rademaker wrote:
 
 Hi,
 
  You would think so, however every doc I read (including the one you
  pointed out to me) told me that perl gives me a warning:
  
  Variable $foo will not stay shared at 
  
  I do use -w so I should get that warning, but I don't. The variable stays
  defined, but it doesn't have the value of the old variable, it just passes
  the defined($foo) test but the value has changed to an empty array (from a
  full array).
 
 -w has no effect, read the guide again and use PerlWarn On :-)
 
 Bye,
 remco
 
 /--\
 | Remco Schaar |
 | e-mail: [EMAIL PROTECTED]  |
 \--/
 
 South Park meets Linux:
 - "Oh my God, they killed init!"
 - "You bastards!"
 




Re: Apache::Registry() and strict

2000-11-07 Thread Simon_Wilcox


Are you running with httpd -X ?

  What you describe sounds like it "stops working" when it hits a child for
  the second time.

  As advised, all this is described in the guide. You might want to start
  here:

http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret

HTH,

Simon.







   From   Ron Rademaker [EMAIL PROTECTED]
  Date   7 November 2000


To  
[EMAIL PROTECTED] Time  09:42 



  Copy to[EMAIL PROTECTED] (bcc: Simon Wilcox/BASE/WilliamsLea)



  Bcc Simon Wilcox/BASE/WilliamsLea



  Fax to



  Subject   Re: Apache::Registry() and strict





Just tried, it didn't give me any useful information, I always got any
other warning without PerlWarn on, so I don't think it made any
difference. Anyway, even with PerlWarn on, the error.log still shows
exactly the same output, everything goes well for a while, but then
suddenly my defined($foo) check succeeds where it should have failed, but
the old value is gone.

Ron











__


   This email contains proprietary information some or all of which may be
   legally privileged.  It is for the intended recipient only. If an addressing
   or transmission error has misdirected this email, please notify the author by
   replying to this email. If you are not the intended recipient you must not
   use, disclose, distribute, copy, print, or reply on this email.





Re: Apache::Registry() and strict

2000-11-07 Thread G.W. Haywood

Hi there,

On Tue, 7 Nov 2000, Ron Rademaker wrote:

 Just tried, it didn't give me any useful information,...

Try 'httpd -X'.

73,
Ged.




Re: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

I just read that part of the guide, for the third time today, but still I
didn't see anything that could help, I don't get any warnings and I'm not
using globals. The problem does occur when trying to use a child more then
once. So when I tried running with httpd -X I got the wrong output the
second time.

Ron

On Tue, 7 Nov 2000 [EMAIL PROTECTED] wrote:

 
 Are you running with httpd -X ?
 
   What you describe sounds like it "stops working" when it hits a child for
   the second time.
 
   As advised, all this is described in the guide. You might want to start
   here:
 
 http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret
 
 HTH,
 
 Simon.
 
 
 
 
 
 
 
From   Ron Rademaker [EMAIL PROTECTED]
   Date   7 November 2000
 
 
 To  
 [EMAIL PROTECTED] Time  09:42 
 
 
 
   Copy to[EMAIL PROTECTED] (bcc: Simon Wilcox/BASE/WilliamsLea)
 
 
 
   Bcc Simon Wilcox/BASE/WilliamsLea
 
 
 
   Fax to
 
 
 
   Subject   Re: Apache::Registry() and strict
 
 
 
 
 
 Just tried, it didn't give me any useful information, I always got any
 other warning without PerlWarn on, so I don't think it made any
 difference. Anyway, even with PerlWarn on, the error.log still shows
 exactly the same output, everything goes well for a while, but then
 suddenly my defined($foo) check succeeds where it should have failed, but
 the old value is gone.
 
 Ron
 
 
 
 
 
 
 
 
 
 
 
 __
 
 
This email contains proprietary information some or all of which may be
legally privileged.  It is for the intended recipient only. If an addressing
or transmission error has misdirected this email, please notify the author by
replying to this email. If you are not the intended recipient you must not
use, disclose, distribute, copy, print, or reply on this email.
 
 




Re: Apache::Registry() and strict

2000-11-07 Thread Simon_Wilcox


Then it is definitely variable persistence !

  If you really can't track down the bug, you might try posting your code to
  the list.

  Perhaps someone will spot something you've missed ?

  Simon.






   From   Ron Rademaker [EMAIL PROTECTED]
  Date   7 November 2000


To  
Simon Wilcox/BASE/WilliamsLea@WilliamsLea   Time  10:04 



  Copy to[EMAIL PROTECTED]



  Bcc



  Fax to



  Subject   Re: Apache::Registry() and strict





I just read that part of the guide, for the third time today, but still I
didn't see anything that could help, I don't get any warnings and I'm not
using globals. The problem does occur when trying to use a child more then
once. So when I tried running with httpd -X I got the wrong output the
second time.

Ron












__


   This email contains proprietary information some or all of which may be
   legally privileged.  It is for the intended recipient only. If an addressing
   or transmission error has misdirected this email, please notify the author by
   replying to this email. If you are not the intended recipient you must not
   use, disclose, distribute, copy, print, or reply on this email.





Re: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

Okay, here's the part where it's going wrong:

my @fields; # The variable that's causing the trouble, should be
undefined after this declaration
my $printedfields = 0;

foreach my $hash_ref (@$data_ref)
{
if (!defined(@fields)) # Passes the second time the child gets a
request, but @fields = ()
{
@fields = @$hash_ref;
}
else
{
print "tr";
if (!$printedfields)
{
$printedfields = 1;
foreach my $field (@fields)
{
print "th$$hash_ref{$field}/th";
}
print "/tr";
}
else
{
foreach my $found (@fields)
{
print "td align='center'";
my $tempfound = $found;
my $unitskey = $tempfound . "units";
my $printed = 0;
if (defined($$hash_ref{$unitskey}))
{
print "$$hash_ref{$unitskey}$$hash_ref{$found}";
$printed = 1;
}
$tempfound =~ s/min//;
$tempfound =~ s/max//;
$unitskey = $tempfound . "units";
if (defined($$hash_ref{$unitskey})  !$printed)
{
print "$$hash_ref{$found} $$hash_ref{$unitskey}";
}
elsif(!$printed)
{
print "$$hash_ref{$found}";
}
print "/td";
}
print "/tr";
print "tr/trtr/trtrtd
colspan='$#fields'$$hash_ref{productlongdescription}/td/tr" if
(($url_ref eq "")  (defined($$hash_ref{productlongdescription})) 
($specdb eq ""));
print "trtd colspan='$#fields' align='center'a
href='/cgi-bin/order.cgi?productcode=$$hash_ref{productcode}number=1'Bestel
dit product/a/td/tr"; # Second run causes a use of unititialised
value here, will be solved if defined checks does what is should
}
}
}

On Tue, 7 Nov 2000 [EMAIL PROTECTED] wrote:

 
 Then it is definitely variable persistence !
 
   If you really can't track down the bug, you might try posting your code to
   the list.
 
   Perhaps someone will spot something you've missed ?
 
   Simon.
 
 
 
 
 
 
From   Ron Rademaker [EMAIL PROTECTED]
   Date   7 November 2000
 
 
 To  
 Simon Wilcox/BASE/WilliamsLea@WilliamsLea   Time  10:04 
             
 
 
   Copy to[EMAIL PROTECTED]
 
 
 
   Bcc
 
 
 
   Fax to
 
 
 
   Subject   Re: Apache::Registry() and strict
 
 
 
 
 
 I just read that part of the guide, for the third time today, but still I
 didn't see anything that could help, I don't get any warnings and I'm not
 using globals. The problem does occur when trying to use a child more then
 once. So when I tried running with httpd -X I got the wrong output the
 second time.
 
 Ron
 
 
 
 
 
 
 
 
 
 
 
 
 __
 
 
This email contains proprietary information some or all of which may be
legally privileged.  It is for the intended recipient only. If an addressing
or transmission error has misdirected this email, please notify the author by
replying to this email. If you are not the intended recipient you must not
use, disclose, distribute, copy, print, or reply on this email.
 
 




Re: Apache::Registry() and strict

2000-11-07 Thread lporcano

It looks like you are trying to determine if an array is empty, in that case
replace
if (!defined(@fields))
with
if (!scalar(@fields)).

- Original Message -
From: Ron Rademaker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, November 07, 2000 5:26 AM
Subject: Re: Apache::Registry() and strict


 Okay, here's the part where it's going wrong:

 my @fields; # The variable that's causing the trouble, should be
 undefined after this declaration
 my $printedfields = 0;

 foreach my $hash_ref (@$data_ref)
 {
 if (!defined(@fields)) # Passes the second time the child gets a
 request, but @fields = ()
 {
 @fields = @$hash_ref;
 }
 else
 {
 print "tr";
 if (!$printedfields)
 {
 $printedfields = 1;
 foreach my $field (@fields)
 {
 print "th$$hash_ref{$field}/th";
 }
 print "/tr";
 }
 else
 {
 foreach my $found (@fields)
 {
 print "td align='center'";
 my $tempfound = $found;
 my $unitskey = $tempfound . "units";
 my $printed = 0;
 if (defined($$hash_ref{$unitskey}))
 {
 print "$$hash_ref{$unitskey}$$hash_ref{$found}";
 $printed = 1;
 }
 $tempfound =~ s/min//;
 $tempfound =~ s/max//;
 $unitskey = $tempfound . "units";
 if (defined($$hash_ref{$unitskey})  !$printed)
 {
 print "$$hash_ref{$found} $$hash_ref{$unitskey}";
 }
 elsif(!$printed)
 {
 print "$$hash_ref{$found}";
 }
 print "/td";
 }
 print "/tr";
 print "tr/trtr/trtrtd
 colspan='$#fields'$$hash_ref{productlongdescription}/td/tr" if
 (($url_ref eq "")  (defined($$hash_ref{productlongdescription})) 
 ($specdb eq ""));
 print "trtd colspan='$#fields' align='center'a

href='/cgi-bin/order.cgi?productcode=$$hash_ref{productcode}number=1'Beste
l
 dit product/a/td/tr"; # Second run causes a use of unititialised
 value here, will be solved if defined checks does what is should
 }
 }
 }

 On Tue, 7 Nov 2000 [EMAIL PROTECTED] wrote:

 
  Then it is definitely variable persistence !
 
If you really can't track down the bug, you might try posting your
code to
the list.
 
Perhaps someone will spot something you've missed ?
 
Simon.
 
 
 
 
 
 
 From   Ron Rademaker
[EMAIL PROTECTED]
Date   7 November 2000
 
 
  To
  Simon Wilcox/BASE/WilliamsLea@WilliamsLea   Time  10:04
 
 
 
Copy to[EMAIL PROTECTED]
 
 
 
Bcc
 
 
 
Fax to
 
 
 
Subject   Re: Apache::Registry() and strict
 
 
 
 
 
  I just read that part of the guide, for the third time today, but still
I
  didn't see anything that could help, I don't get any warnings and I'm
not
  using globals. The problem does occur when trying to use a child more
then
  once. So when I tried running with httpd -X I got the wrong output the
  second time.
 
  Ron
 
 
 
 
 
 
 
 
 
 
 
 
  __
 
 
 This email contains proprietary information some or all of which may
be
 legally privileged.  It is for the intended recipient only. If an
addressing
 or transmission error has misdirected this email, please notify the
author by
 replying to this email. If you are not the intended recipient you
must not
 use, disclose, distribute, copy, print, or reply on this email.
 
 






Re: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

I'm not quite looking for a workaround, I already got one, I'd like to
know why it's going wrong.

Ron

On Sun, 7 Nov 1999, lporcano wrote:

 It looks like you are trying to determine if an array is empty, in that case
 replace
 if (!defined(@fields))
 with
 if (!scalar(@fields)).
 
 - Original Message -
 From: Ron Rademaker [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Tuesday, November 07, 2000 5:26 AM
 Subject: Re: Apache::Registry() and strict
 
 
  Okay, here's the part where it's going wrong:
 
  my @fields; # The variable that's causing the trouble, should be
  undefined after this declaration
  my $printedfields = 0;
 
  foreach my $hash_ref (@$data_ref)
  {
  if (!defined(@fields)) # Passes the second time the child gets a
  request, but @fields = ()
  {
  @fields = @$hash_ref;
  }
  else
  {
  print "tr";
  if (!$printedfields)
  {
  $printedfields = 1;
  foreach my $field (@fields)
  {
  print "th$$hash_ref{$field}/th";
  }
  print "/tr";
  }
  else
  {
  foreach my $found (@fields)
  {
  print "td align='center'";
  my $tempfound = $found;
  my $unitskey = $tempfound . "units";
  my $printed = 0;
  if (defined($$hash_ref{$unitskey}))
  {
  print "$$hash_ref{$unitskey}$$hash_ref{$found}";
  $printed = 1;
  }
  $tempfound =~ s/min//;
  $tempfound =~ s/max//;
  $unitskey = $tempfound . "units";
  if (defined($$hash_ref{$unitskey})  !$printed)
  {
  print "$$hash_ref{$found} $$hash_ref{$unitskey}";
  }
  elsif(!$printed)
  {
  print "$$hash_ref{$found}";
  }
  print "/td";
  }
  print "/tr";
  print "tr/trtr/trtrtd
  colspan='$#fields'$$hash_ref{productlongdescription}/td/tr" if
  (($url_ref eq "")  (defined($$hash_ref{productlongdescription})) 
  ($specdb eq ""));
  print "trtd colspan='$#fields' align='center'a
 
 href='/cgi-bin/order.cgi?productcode=$$hash_ref{productcode}number=1'Beste
 l
  dit product/a/td/tr"; # Second run causes a use of unititialised
  value here, will be solved if defined checks does what is should
  }
  }
  }
 
  On Tue, 7 Nov 2000 [EMAIL PROTECTED] wrote:
 
  
   Then it is definitely variable persistence !
  
 If you really can't track down the bug, you might try posting your
 code to
 the list.
  
 Perhaps someone will spot something you've missed ?
  
 Simon.
  
  
  
  
  
  
  From   Ron Rademaker
 [EMAIL PROTECTED]
 Date   7 November 2000
  
  
   To
   Simon Wilcox/BASE/WilliamsLea@WilliamsLea   Time  10:04
  
  
  
 Copy to[EMAIL PROTECTED]
  
  
  
 Bcc
  
  
  
 Fax to
  
  
  
 Subject   Re: Apache::Registry() and strict
  
  
  
  
  
   I just read that part of the guide, for the third time today, but still
 I
   didn't see anything that could help, I don't get any warnings and I'm
 not
   using globals. The problem does occur when trying to use a child more
 then
   once. So when I tried running with httpd -X I got the wrong output the
   second time.
  
   Ron
  
  
  
  
  
  
  
  
  
  
  
  
   __
  
  
  This email contains proprietary information some or all of which may
 be
  legally privileged.  It is for the intended recipient only. If an
 addressing
  or transmission error has misdirected this email, please notify the
 author by
  replying to this email. If you are not the intended recipient you
 must not
  use, disclose, distribute, copy, print, or reply on this email.
  
  
 
 
 




Re: Apache::Registry() and strict

2000-11-07 Thread lporcano

 I'm not quite looking for a workaround, I already got one, I'd like to
 know why it's going wrong.


From the perlfunc page:

defined - Returns a Boolean value telling whether EXPR has a value

other than the undefined value undef. [...] On the other hand, use

of defined() upon aggregates (hashes and arrays) is not guaranteed to

produce intuitive results, and should probably be avoided.



Len





RE: Apache::Registry() and strict

2000-11-07 Thread Geoffrey Young


from the camel book: "Use of defined on aggregates (hashes and arrays) is
deprecated."

so, change

if (!defined @fields)

to

unless (@fields)

and not only be idiomatic, but exhibit the behavior you want :)

but seriously, it's a perl thing, not a mod_perl thing:

#!/usr/bin/perl
sub test {
  my @array;

  if (!defined @array) {
print "not defined\n";
  } else {
print "defined\n";
  }

  push @array, "item";
}

test();
test();

results:
not defined
defined

HTH

--Geoff


 -Original Message-
 From: Ron Rademaker [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 07, 2000 7:44 AM
 To: lporcano
 Cc: [EMAIL PROTECTED]
 Subject: Re: Apache::Registry() and strict
 
 
 I'm not quite looking for a workaround, I already got one, I'd like to
 know why it's going wrong.
 
 Ron
 
 On Sun, 7 Nov 1999, lporcano wrote:
 
  It looks like you are trying to determine if an array is 
 empty, in that case
  replace
  if (!defined(@fields))
  with
  if (!scalar(@fields)).
  
  - Original Message -
  From: Ron Rademaker [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Tuesday, November 07, 2000 5:26 AM
  Subject: Re: Apache::Registry() and strict
  
  
   Okay, here's the part where it's going wrong:
  
   my @fields; # The variable that's causing the 
 trouble, should be
   undefined after this declaration
   my $printedfields = 0;
  
   foreach my $hash_ref (@$data_ref)
   {
   if (!defined(@fields)) # Passes the second time the child gets a
   request, but @fields = ()
   {
   @fields = @$hash_ref;
   }
[snip]



RE: Apache::Registry() and strict

2000-11-07 Thread Ron Rademaker

Okay, thanks (everyone).

On Tue, 7 Nov 2000, Geoffrey Young wrote:

 
 from the camel book: "Use of defined on aggregates (hashes and arrays) is
 deprecated."
 
 so, change
 
 if (!defined @fields)
 
 to
 
 unless (@fields)
 
 and not only be idiomatic, but exhibit the behavior you want :)
 
 but seriously, it's a perl thing, not a mod_perl thing:
 
 #!/usr/bin/perl
 sub test {
   my @array;
 
   if (!defined @array) {
 print "not defined\n";
   } else {
 print "defined\n";
   }
 
   push @array, "item";
 }
 
 test();
 test();
 
 results:
 not defined
 defined
 
 HTH
 
 --Geoff
 
 
  -Original Message-
  From: Ron Rademaker [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, November 07, 2000 7:44 AM
  To: lporcano
  Cc: [EMAIL PROTECTED]
  Subject: Re: Apache::Registry() and strict
  
  
  I'm not quite looking for a workaround, I already got one, I'd like to
  know why it's going wrong.
  
  Ron
  
  On Sun, 7 Nov 1999, lporcano wrote:
  
   It looks like you are trying to determine if an array is 
  empty, in that case
   replace
   if (!defined(@fields))
   with
   if (!scalar(@fields)).
   
   - Original Message -
   From: Ron Rademaker [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Cc: [EMAIL PROTECTED]
   Sent: Tuesday, November 07, 2000 5:26 AM
   Subject: Re: Apache::Registry() and strict
   
   
Okay, here's the part where it's going wrong:
   
my @fields; # The variable that's causing the 
  trouble, should be
undefined after this declaration
my $printedfields = 0;
   
foreach my $hash_ref (@$data_ref)
{
if (!defined(@fields)) # Passes the second time the child gets a
request, but @fields = ()
{
@fields = @$hash_ref;
}
 [snip]
 




Re: Apache::Registry() and strict

2000-11-07 Thread Paul DuBois

At 10:25 AM +0100 11/7/00, [EMAIL PROTECTED] wrote:
On Tue, 7 Nov 2000, Ron Rademaker wrote:

Hi,

  You would think so, however every doc I read (including the one you
  pointed out to me) told me that perl gives me a warning:

  Variable $foo will not stay shared at 

  I do use -w so I should get that warning, but I don't. The variable stays
  defined, but it doesn't have the value of the old variable, it just passes
  the defined($foo) test but the value has changed to an empty array (from a
  full array).

-w has no effect, read the guide again and use PerlWarn On :-)

Please explain, the guide appears to recommend -w as a useful
diagnostic technique (and the "Command Line Switches (-w, -T,
etc)" section says -w works).


Bye,
remco

/--\
| Remco Schaar |
| e-mail: [EMAIL PROTECTED]  |
\--/

 South Park meets Linux:
 - "Oh my God, they killed init!"
 - "You bastards!"