Re: help with defined and !not defined
I see, that's a really bad example and I can see why it would confuse. Variables in perl don't have a true undefined state like say C might. Because of autovivification, *all* variables are in a state of potential existence. Once u reference a variable, it comes into existence with the undefined value. defined() see's if a variable has the undef value or something else, including null. So in ur example below it should be a's value is not undef not a has a value. In perl defined means has anything every been assigned to x. At 07:27 AM 7/22/05 -0700, lorid wrote: you are right about I should test for null or length of value instead but I found the place where I got information that says that to be defined a var must have a value: Beginnng Perl by Simon Cozens pg 123: We can test if a variable is defined by... my $a; my $b; $b = 10; if (defined $a){ print a has a value.\n; } if (defined $b){ print b has a value.\n; } #only prints b has a value -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede males 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: help with defined and !not defined
On Fri, 22 Jul 2005 12:05:16 -0700, you wrote: You want to check if it's null, not if it's defined. Defined means that the variable exists. Almost. Defined means the variable exists AND its value is not undef, as this snippet demonstrates: my $foo; print !defined $foo; As for the OP's question, substr() does indeed return undef if the offset and length specification refers to something completely outside the string argument. I suspect that the elements of @ARGV have newlines or other whitespace at the end that are causing a problem. -- Eric Amick Columbia, MD ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: help with defined and !not defined
-Original Message- From: lorid Im want to set the $photo_year and $photo_month to another value if it is not already set. my $ARGV[0] will sometimes be passed a string like this:nvIGRA with no date at end and sometimes with date nvIGRA200511 if it does not have date I need to set it another way but cant get syntax of !defined this will work: my $filename = $ARGV[0]; if ( $filename =~ /nvIGRA(\d{4})(\d{2})/ ) { my $photo_year=$1; my $photo_month=$2; } $photo_year=2005 unless defined $photo_year; $photo_month=7 unless defined $photo_month; if ($photo_month10) { $photo_month=0.$photo_month; } note: if you can have other strings other than nvIGRA change that part into a regular expression. my $filename = $ARGV[0]; my $photo_year; $photo_year= substr($filename,6,4); my $photo_month ; $photo_month= substr($filename,10,2); #This just blows my web page if(!defined $photo_year){ $photo_year =2005; } #I have also tried if(defined $qphoto_year){ #test $test1 =Im defined; } else{ $test2 =Im Not defined; print $test2; } How come It always returns Im defined ,even when no date is passed should I do some kind of checking on my $ARGV[0] before doing the asignment $photo_year= substr($filename,6,4); help appreciated thanks lori ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
setting password for awstats.pl
We're using awstats to publish our webstats. I'm not too familiar with using .pl files to display web information. Is there a way to modify the code for awstats, so that the page requires a password to view. Not too sure how to do this. Also, we want to give the password to our client, but we donnot want to give them our adminstrator password or any password that allows them to remote admin into our system. Thanks for any advise you can give on how to accomplish this... ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32:API Problem
$Bill Luebkert [EMAIL PROTECTED] wrote on 07/22/2005 07:19:56 PM: David Legault wrote: Hello, I'm trying to use the Win32:API module to access a DLL function with this perl code : $function = Win32::API-new( 'test.dll', 'int startSimulation(int eRunMode)', ); Try an alternate calling method and see if it makes a diff : my $function = Win32::API-new('test.dll', 'i', 'i') or die import: $! ($^E); my $return = $function-Call(0); or my $startSimulation = Win32::API-Import('test.dll', 'int startSimulation (int eRunMode)') or die import startSimulation: $! ($^E); my $return = startSimulation (0); print $return\n; $return = $function-Call(0); print $return; The C code for the function in the DLL is : int startSimulation( int eRunMode ) { return 0; } Which is very basic and the Symbol is exported with a .def file. When I run the perl code, it crashes with a pointer to NULL memory access. If anyone has a clue on why this is happening, or has a fix for it, I'd be glad to know. P.S. I also tried WJ patched version available at http://www.xs4all.nl/~itsme/projects/perl/ with the same result. I experienced a similar problem with accessing a vendor DLL from Perl. The cdecl calling convention was the culprit and using http://www.xs4all.nl/~itsme/projects/perl/ Win32::API package resolved it. If you provide the DLL (or at least a makefile), I'm willing to try to access it from Perl. Lloyd ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: setting password for awstats.pl
Ted Yu wrote: We're using awstats to publish our webstats. I'm not too familiar with using .pl files to display web information. Is there a way to modify the code for awstats, so that the page requires a password to view. Not too sure how to do this. Also, we want to give the password to our client, but we donnot want to give them our adminstrator password or any password that allows them to remote admin into our system. This is all part of your server setup - you can restrict access to a script and password protect it. See Apache or IIS docs to resolve (depending on which you're using). -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /-- o // // Castle of Medieval Myth Magic http://www.todbe.com/ -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs