Re: When does a hash of lists get defined?
Actually, those mean different things. Neither autovivifies, which was what Doug was seeking to understand. Both defined $phash{D}[3] and exists $phash{D}[3] autovivify $phash{D}. - Bruce 'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps. Stewart -- Stewart Leicester | JenSoft Technologies, LLC Per Ardua Ad Astra | mailto:[EMAIL PROTECTED]
Re: When does a hash of lists get defined?
On 4/5/06 Stewart Leicester wrote: Bruce Van Allen wrote: Both defined $phash{D}[3] and exists $phash{D}[3] autovivify $phash{D}. - Bruce 'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps. Oh? Try this: #!/usr/bin/perl -w use strict; my %hash= ( A = [qw/a0 a1 a2/], ); # $hash{A} if (defined $hash{A}[2]) { print OK \$hash{A}[2] defined\n } if (exists $hash{A}[2]) { print OK \$hash{A}[2] exists\n } # test defined() on $hash{B} if (defined $hash{B}[2]) { print OK \$hash{B}[2] defined\n } elsif (exists $hash{B}) { print OK \$hash{B} exists: autovivified from defined()\n } # test exists() on $hash{D} if (exists $hash{D}[2]) { print OK \$hash{D}[2] exists\n } elsif (exists $hash{D}) { print OK \$hash{D} exists: autovivified from exists()\n } __END__ prints: OK $hash{A}[2] defined OK $hash{A}[2] exists OK $hash{B} exists: autovivified from defined() OK $hash{D} exists: autovivified from exists() The autovivification is happening when the values are dereferenced. The expression exists $hash{D}[2] is testing the existence of the third element in the array ref ostensibly stored in $hash{D}, so $hash{D} gets autovivified to allow the test. 1; - Bruce __bruce__van_allen__santa_cruz__ca__
Re: When does a hash of lists get defined?
On Apr 5, 2006, at 11:41 AM, Stewart Leicester wrote: Actually, those mean different things. Neither autovivifies, which was what Doug was seeking to understand. Both defined $phash{D}[3] and exists $phash{D}[3] autovivify $phash{D}. - Bruce 'defined' will autovivify, 'exists' will not. No, Bruce is right. When used with nested structures, both defined() and exists() will create the hash element D, and store a reference to an anonymous array in it. But don't take my word for it - just ask Perl. Here's a simple test: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %def_hash; my %ex_hash; my $foo = defined($def_hash{'D'}[3]); print Using defined():\n, Dumper(\%def_hash), \n; my $bar = exists($ex_hash{'D'}[3]); print Using exists():\n, Dumper(\%ex_hash), \n; This prints: Using defined(): $VAR1 = { 'D' = [] }; Using exists(): $VAR1 = { 'D' = [] }; sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: When does a hash of lists get defined?
At 08:41 -0700 4/5/06, Stewart Leicester wrote: 'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps. The Camel book, page 710 in the third edition is very clear that exists goes the same way as defined. But perl has gone through a couple of new versions since it was written. Thanks to Stewart who did get me on the right track by mentioning exists. That's where I found autovivification mentioned in the Bible. It also says there: This behavior is likely to be fixed in a future release. In 5.8.1-RC3 it hasn't changed. I wonder if the comment refers to perl6 ? Do those fellows know about it? The solution for my problem was to test just the hash element without looking at the underlying list item. Exists and defined both work that way without behaving like the Creator. Checking for the list item = also works if the vivifivation has occurred. I appreciate the help from the list -- -- Science is the business of discovering and codifying the rules and methods employed by the Intelligent Designer. Religions provide myths to mollify the anxiety experienced by those who choose not to participate. --
Install Apache, mod_perl
Hello all, this is my first posting here and I am not such a pro as you all around here ... I want to install a local mysql-server and I am new to mysql. I installed everything as asked in my first mysql-book (MySQL Perl, Developer's Guide, Paul DuBois). Only over mod_perl and Bundle::DBD my cpan is refusing to proceed to installation. So I tried it manually. To achieve this I installed a fresh Perl ( v5.8.8 running on MacOS 10.3.9) and then I installed also an updated Apache. But I suppose there is something wrong with my permissions. The installation was like follows: I download and untar Apache and mod_perl into /usr/local/src The Apache-Server is installed without any options to the default folders like follows, but *with* sudo: % ./config #without anything behind % make make test % sudo make make test % sudo apachectl start It seems to work. But impossible to compile mod_perl ... Permission issue? Already % perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs issuing: Reading Makefile.PL args from @ARGV MP_APXS = /usr/local/apache2/bin/apxs no conflicting prior mod_perl version found - good. Configuring Apache/2.2.0*/ mod_perl2/2.0.2 Perl/v5.8.8 open /usr/local/src/mod_perl-2.0.2/lib/Apache2/BuildConfig.pm: Permission denied at lib/Apache2/Build.pm line 939. so I do it with sudo ... issuing after many Writing Makefile for ... [warning] mod_perl dso library will be built as mod_perl.so [warning] You'll need to add the following to httpd.conf: [warning] [warning] LoadModule perl_module modules/mod_perl.so [warning] [warning] depending on your build, mod_perl might not live in [warning] the modules/ directory. [warning] Check the results of [warning] [warning] $ /usr/local/apache2/bin/apxs -q LIBEXECDIR [warning] [warning] and adjust the LoadModule directive accordingly. So I change /usr/local/apache2/conf/httpd.conf and put at the end of the file: /usr/local/apache2/conf/httpd.conf is this right? then I do: [markslap:/usr/local/src/mod_perl-2.0.2] mareklap% make make test cd src/modules/perl make cc -I/usr/local/src/mod_perl-2.0.2/src/modules/perl -I/usr/local/src/mod_perl-2.0.2/xs -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/local/lib/perl5/5.8.8/darwin-2level/CORE -DMOD_PERL -DMP_COMPAT_1X -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -Os \ -c mod_perl.c mv mod_perl.o mod_perl.lo {standard input}:unknown:FATAL:can't create output file: mod_perl.o make[1]: *** [mod_perl.lo] Error 1 make: *** [modperl_lib] Error 2 I do the same with sudo : % sudo !! which seems to work but after some hard and impressing work - there are people out there, which not only understand these lines, but also have written all this stuff in their code!!! - appears some errors: using Apache/2.2.0 (prefork MPM) waiting 120 seconds for server to start: .[Wed Apr 05 14:22:27 2006] [info] 6 Apache2:: modules loaded [Wed Apr 05 14:22:27 2006] [info] 0 APR:: modules loaded [Wed Apr 05 14:22:27 2006] [info] base server + 27 vhosts ready to run tests .[ error] Failed to find a config file to save the custom configuration in . (in cleanup) Can't open /usr/local/src/mod_perl-2.0.2/t/conf/perlsection.conf: Permission denied at /usr/local/src/mod_perl-2.0.2/t/conf/extra.last.conf line 56. Syntax error on line 54 of /usr/local/src/mod_perl-2.0.2/t/conf/extra.last.conf: \t(in cleanup) Can't open /usr/local/src/mod_perl-2.0.2/t/conf/perlsection.conf: Permission denied at /usr/local/src/mod_perl-2.0.2/t/conf/extra.last.conf line 56.\n ... waiting 120 seconds for server to start: not ok [ error] giving up after 121 secs. If you think that your system is slow or overloaded try again with a longer timeout value. by setting the environment variable APACHE_TEST_STARTUP_TIMEOUT to a high value (e.g. 420) and repeat the last command. [ error] server failed to start! (t/logs/error_log wasn't created, start the server in the debug mode) ++ | Please file a bug report: http://perl.apache.org/bugs/ | ++ make: *** [run_tests] Error 1 And with running Apache it is the same! But I can start Apache only as root: % apachectl start Processing config directory: /private/etc/httpd/users/*.conf fopen: Permission denied httpd: could not open error log file /private/var/log/httpd/error_log. /usr/sbin/apachectl start: httpd could not be started Sorry for this long posting. greetings to all from Munich (winter is back) marek -- ___ the embassy for talented young musicians Podium International | Marek Stepanek | [EMAIL
Re: Install Apache, mod_perl
On 4/5/06 at 11:14 PM, [EMAIL PROTECTED] (Marek Stepanek) wrote: % perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs [warning] mod_perl dso library will be built as mod_perl.so [warning] You'll need to add the following to httpd.conf: [warning] [warning] LoadModule perl_module modules/mod_perl.so [warning] [warning] depending on your build, mod_perl might not live in [warning] the modules/ directory. [warning] Check the results of [warning] [warning] $ /usr/local/apache2/bin/apxs -q LIBEXECDIR [warning] [warning] and adjust the LoadModule directive accordingly. So I change /usr/local/apache2/conf/httpd.conf and put at the end of the file: /usr/local/apache2/conf/httpd.conf is this right? No, it's saying add 'LoadModule perl_module modules/mod_perl.so' (no quotes) to your httpd.conf file which is *located* at /usr/local/apache2/conf/httpd.conf. You will likely see many other LoadModule directives in the file, add it there. It also warns that your mod_perl may be located other than at {server root}/modules/mod_perl.so, so you may want to double check that. Regards, Andrew -- Andrew Brosnan - Broscom LLC - 1 207 925-1156 [EMAIL PROTECTED] - http://www.broscom.com Programming, Consulting, Websites, Hosting
Re: When does a hash of lists get defined?
'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps. The Camel book, page 710 in the third edition is very clear that exists goes the same way as defined. But perl has gone through a couple of new versions since it was written. Thanks to Stewart who did get me on the right track by mentioning exists. That's where I found autovivification mentioned in the Bible. It also says there: This behavior is likely to be fixed in a future release. In 5.8.1-RC3 it hasn't changed. I wonder if the comment refers to perl6 ? Do those fellows know about it? I'm going to shoot myself in the foot before I check the docs, but I look at the look-ahead and look-behind perl has to take with if ( funxyz( $a_hash{ D } ) and if ( funxyz( $a_hash_ref{ D }[ $x ] ) and I think I don't want perl trying to differentiate what exists() and defined() do in any but the most simple case. I think the English semantics of defined vs. exists is plenty to deal with, anyway. The solution for my problem was to test just the hash element without looking at the underlying list item. Exists and defined both work that way without behaving like the Creator. Checking for the list item = also works if the vivifivation has occurred. if ( defined( $a_hash_ref ) $defined( $a_hash_ref{ D } ) defined( $a_hash_ref{ D }[ $x ] ) ) although we usually know which of those tests we can leave out if we stop to think.
Re: When does a hash of lists get defined?
'defined' will autovivify, 'exists' will not. No, Bruce is right. When used with nested structures, both defined() and exists() will create the hash element D, and store a reference to an anonymous array in it. But don't take my word for it - just ask Perl. Here's a simple test: Oops, you're right, I'm wrong. Certainly caused a quick discussion, though, didn't it? :-) I was thinking of this from the docs: The element is not autovivified if it doesn't exist. but obviously forgot about the creation of intervening elements. Teach me to reply before reviewing! Stewart -- Stewart Leicester | JenSoft Technologies, LLC Per Ardua Ad Astra | mailto:[EMAIL PROTECTED]
FW: Install Apache, mod_perl
-- Weitergeleitete Nachricht Von: Marek Stepanek [EMAIL PROTECTED] Datum: Wed, 05 Apr 2006 23:58:23 +0200 An: Andrew Brosnan [EMAIL PROTECTED] Unterhaltung: Install Apache, mod_perl Betreff: Re: Install Apache, mod_perl On 05.04.2006 23:20, Andrew Brosnan [EMAIL PROTECTED] wrote: On 4/5/06 at 11:14 PM, [EMAIL PROTECTED] (Marek Stepanek) wrote: % perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs [warning] mod_perl dso library will be built as mod_perl.so [warning] You'll need to add the following to httpd.conf: [warning] [warning] LoadModule perl_module modules/mod_perl.so [warning] [warning] depending on your build, mod_perl might not live in [warning] the modules/ directory. [warning] Check the results of [warning] [warning] $ /usr/local/apache2/bin/apxs -q LIBEXECDIR [warning] [warning] and adjust the LoadModule directive accordingly. So I change /usr/local/apache2/conf/httpd.conf and put at the end of the file: /usr/local/apache2/conf/httpd.conf is this right? No, it's saying add 'LoadModule perl_module modules/mod_perl.so' (no quotes) to your httpd.conf file which is *located* at /usr/local/apache2/conf/httpd.conf. You will likely see many other LoadModule directives in the file, add it there. It also warns that your mod_perl may be located other than at {server root}/modules/mod_perl.so, so you may want to double check that. Regards, Andrew thanx Andrew, this was an error of copy and paste. I put to the config file LoadModule perl_module modules/mod_perl.so without quotes ... will be back tomorrow evening. marek -- ___ the embassy for talented young musicians Podium International | Marek Stepanek | [EMAIL PROTECTED] http://www.PodiumInternational.org ___ -- Ende der weitergeleiteten Nachricht ___ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com