OT: defined(@array) v. if(@array) WAS: Re: Should I note any concerns?
yes - i agree - but i think it is strict or strict vars, not strict subs or refs. Ed Phillips wrote: > with the caveat that if(@array) will produce a warning under strict sub refs if as >yet undefined. > You may sometimes still want to use defined. > > comments? > > Ed > > ___cliff rayman___ wrote: > > > you may want to see if there is a later Apache::DBI.pm. > > i did not look at the code but normally: > > > > if (defined(@array)) > > > > should be replaced by: > > > > if(@array) > > > > from perldoc -f defined > > > > Currently, using C on an entire array or hash reports whether > > memory for that aggregate has ever been allocated. So an array you set > > to the empty list appears undefined initially, and one that once was full > > and that you then set to the empty list still appears defined. You > > should instead use a simple test for size: > > > > if (@an_array) { print "has array elements\n" } > > if (%a_hash) { print "has hash members\n" } > > > > -- > > ___cliff [EMAIL PROTECTED] > > > > The Doctor wrote: > > > > > I get the following on startup: > > > > > > Script started on Fri May 26 12:02:56 2000 > > > doctor.nl2k.ab.ca//var/www/conf$ apachectl top stop > > > /usr/contrib/bin/apachectl stop: httpd stopped > > > doctor.nl2k.ab.ca//var/www/conf$ apachectl stop > > > /usr/contrib/bin/apachectl stop: httpd (no pid file) not running > > > doctor.nl2k.ab.ca//var/www/conf$ apachectl stop art > > > defined(@array) is deprecated at >/usr/contrib/lib/perl5/site_perl/5.6.0/Apache/DBI.pm line 135. > > > (Maybe you should just omit the defined()?) > > > /usr/contrib/bin/apachectl start: httpd started > > > doctor.nl2k.ab.ca//var/www/conf$ exit > > > exit > > > > > > Script done on Fri May 26 12:03:31 2000 > > > > > > Using > > > Embedded Perl version v5.6.0 for Apache/1.3.12 BSDI BSD/OS 4.1 (Unix) >mod_fastcgi/2.2.2 DAV/0.9.14 PHP/3.0.15 mod_perl/1.24 > > > FrontPage/4.0.4.3 process 27405, > > > > -- > > ___cliff [EMAIL PROTECTED] -- ___cliff [EMAIL PROTECTED]
Re: Should I note any concerns?
you may want to see if there is a later Apache::DBI.pm. i did not look at the code but normally: if (defined(@array)) should be replaced by: if(@array) from perldoc -f defined Currently, using C on an entire array or hash reports whether memory for that aggregate has ever been allocated. So an array you set to the empty list appears undefined initially, and one that once was full and that you then set to the empty list still appears defined. You should instead use a simple test for size: if (@an_array) { print "has array elements\n" } if (%a_hash) { print "has hash members\n" } -- ___cliff [EMAIL PROTECTED] The Doctor wrote: > I get the following on startup: > > Script started on Fri May 26 12:02:56 2000 > doctor.nl2k.ab.ca//var/www/conf$ apachectl top stop > /usr/contrib/bin/apachectl stop: httpd stopped > doctor.nl2k.ab.ca//var/www/conf$ apachectl stop > /usr/contrib/bin/apachectl stop: httpd (no pid file) not running > doctor.nl2k.ab.ca//var/www/conf$ apachectl stop art > defined(@array) is deprecated at >/usr/contrib/lib/perl5/site_perl/5.6.0/Apache/DBI.pm line 135. > (Maybe you should just omit the defined()?) > /usr/contrib/bin/apachectl start: httpd started > doctor.nl2k.ab.ca//var/www/conf$ exit > exit > > Script done on Fri May 26 12:03:31 2000 > > Using > Embedded Perl version v5.6.0 for Apache/1.3.12 BSDI BSD/OS 4.1 (Unix) >mod_fastcgi/2.2.2 DAV/0.9.14 PHP/3.0.15 mod_perl/1.24 > FrontPage/4.0.4.3 process 27405, -- ___cliff [EMAIL PROTECTED]
Should I note any concerns?
I get the following on startup: Script started on Fri May 26 12:02:56 2000 doctor.nl2k.ab.ca//var/www/conf$ apachectl top stop /usr/contrib/bin/apachectl stop: httpd stopped doctor.nl2k.ab.ca//var/www/conf$ apachectl stop /usr/contrib/bin/apachectl stop: httpd (no pid file) not running doctor.nl2k.ab.ca//var/www/conf$ apachectl stop art defined(@array) is deprecated at /usr/contrib/lib/perl5/site_perl/5.6.0/Apache/DBI.pm line 135. (Maybe you should just omit the defined()?) /usr/contrib/bin/apachectl start: httpd started doctor.nl2k.ab.ca//var/www/conf$ exit exit Script done on Fri May 26 12:03:31 2000 Using Embedded Perl version v5.6.0 for Apache/1.3.12 BSDI BSD/OS 4.1 (Unix) mod_fastcgi/2.2.2 DAV/0.9.14 PHP/3.0.15 mod_perl/1.24 FrontPage/4.0.4.3 process 27405,