[24192] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6384 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 11 00:15:35 2004

Date: Sat, 10 Apr 2004 21:15:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 10 Apr 2004     Volume: 10 Number: 6384

Today's topics:
    Re: file access trouble <invalid-email@rochester.rr.com>
    Re: freesource server control panel for linux server cr <gp@nospm.hr>
    Re: freesource server control panel for linux server cr <wherrera@lynxview.com>
        how call whois information? <gp@nospm.hr>
    Re: how call whois information? <nospam@bigpond.com>
    Re: how call whois information? <matthew.garrish@sympatico.ca>
    Re: Localised sub? <mb@uq.net.au.invalid>
        new bbs <robin @ infusedlight.net>
    Re: Perl Timer ctcgag@hotmail.com
        Random Qs: overloading ==; import <socyl@987jk.com>
        Regexp guestion <ppagee@yahoo.com>
    Re: Regexp guestion (Peter J. Acklam)
    Re: Regexp guestion <tadmc@augustmail.com>
    Re: Regexp guestion (Anno Siegel)
        Returning multiple values <jkrugman@yahbitoo.com>
    Re: Returning multiple values <invalid-email@rochester.rr.com>
    Re: Returning multiple values <jkrugman@yahbitoo.com>
    Re: Returning multiple values <invalid-email@rochester.rr.com>
    Re: Returning multiple values <jkrugman@yahbitoo.com>
    Re: Tests fail in cpan, succeed manually <jkrugman@yahbitoo.com>
    Re: Tests fail in cpan, succeed manually (Jim Keenan)
    Re: Tests fail in cpan, succeed manually (Jim Keenan)
        The value of Truth <socyl@987jk.com>
    Re: The value of Truth <jwillmore@remove.adelphia.net>
        Why are arrays and hashes this way? (Xavier Noria)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 10 Apr 2004 19:25:51 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: file access trouble
Message-Id: <407849F9.3070500@rochester.rr.com>

Chuck wrote:

> I am a new user to perl - trying to teach myself enough perl to do a
> specific task to be used in conjunction with other software I have
> developed.
> 
> I am a software developer and use a web site for distribution of the
> software. The download folder of this web site uses password protection via
> .htpasswd
> 
> I created another windows based program that creates the .htpasswd file
> locally - each of my software users has their own username and password to
> download updates to the software - what I need to do with perl is to loop
> through the local .htpasswd file that is created by the other windows app
> and crypt() the password. I have already done this by looping through the
> local .htpasswd file in my windows based code and copying the password to be
> encrypted to the local clipboard on the computer that I use to maintain my
> user list. Then I call perl from within my windows based code, get the data
> from the clipboard, crypt() the password, and then copy it back to the
> clipboard, then get the clipboard data in my windows based code, and update
> the local .htpasswd file with the encrypted string for the password. Then
> after the process is done I use FTP to upload the .htpasswd file to the
> protected folder on the web server. This all works great but I want to loop
> through the entire file using perl rather that calling perl for each record
> in the file - this is rather slow because perl needs to be loaded for each
> record in the local .htpasswd file rather than only loading once.
> 
> I have been through several tutorials and did google searches to see if I
> could determine why my perl script is not working but could not get it to
> work. I ran the script though the perl debugger and made sure there were no
> errors in the script that the debugger could find. I am using wperl.exe so
> the console window does not show but have also used perl.exe.
> 
> I have been working on this for a couple of days but figured that some help
> from the perl experts could expedite this for me. Any suggestions or
> pointers will be greatly appreciated.
> 
> The script runs without any error messages but does not appear to read data
> from the already existing .htpasswd file and it does not create the new
> .htpasswd2 file that I rename to the original file name after the loop is
> finished - this is my script;
> 
> use strict;
> use warnings;
> 
> my $text1;
> my $text2;
> 
> my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
> my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
> 
> open(OLD, '<', $OldFile) or die "$!\n";
> open(NEW, '>', $NewFile) or die "$!\n";
> 
> while (<OLD>) {
>   $text1 = substr($_,0,5);
>   $text2 = crypt(substr($_,5,8),substr($_,13,2));
>   print NEW "$text1 $text2 /n";

\----------------------------^


> }
> 
> close OLD or die "$!\n";
> close NEW or die "$!\n";
> rename($NewFile,$OldFile) or die "$!\n";
 ...

Seems to work OK for me, copied verbatim (AS Perl build 806 on Windoze 
98SE).  You might want to consider fixing the /n above that looks like 
you probably intended a \n.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Sat, 10 Apr 2004 21:29:44 +0200
From: "PHP2" <gp@nospm.hr>
Subject: Re: freesource server control panel for linux server created with Perl?
Message-Id: <c59htb$phe$1@ls219.htnet.hr>

thank you!
"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:5177504.8EQnfBSt0m@GMT-hosting-and-pickle-farming...
> Gregory Toomey wrote:
>
> I just put my foot in it! Webmin is written in Perl
> http://sourceforge.net/projects/webadmin, but does not need Apache.
>
> gtoomey




------------------------------

Date: Sat, 10 Apr 2004 18:52:55 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: freesource server control panel for linux server created with Perl?
Message-Id: <9Jydndfoa72UCuXdRVn-ig@adelphia.com>

PHP2 wrote:
> do you anyone know about any freesource server control panel for linux
> server created with Perl with features similar like Ensim, Plesk etc.?
> 
> I wish join inside development team..
> 
> 

Webmin is extensible with plug-in modules that may be written in Perl. I 
think that if you wrote a Webmin plug-in for a relevant program that 
needed such a module and that you wanted to control in that way the 
development team might help with testing and so forth.



------------------------------

Date: Sun, 11 Apr 2004 00:03:10 +0200
From: "PHP2" <gp@nospm.hr>
Subject: how call whois information?
Message-Id: <c59qt1$5sp$1@ls219.htnet.hr>

how call whois information for set of domains with Perl?




------------------------------

Date: Sun, 11 Apr 2004 09:32:57 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: how call whois information?
Message-Id: <2428969.zH4ZYbU3kk@GMT-hosting-and-pickle-farming>

PHP2 wrote:

> how call whois information for set of domains with Perl?

You should read the documentation.


my $whois = `whois site.com`

for (split '\n', qx(whois site.com)) {
 ...
}

gtoomey



------------------------------

Date: Sat, 10 Apr 2004 19:40:37 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: how call whois information?
Message-Id: <MB%dc.43428$wq4.2713178@news20.bellglobal.com>


"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:2428969.zH4ZYbU3kk@GMT-hosting-and-pickle-farming...
> PHP2 wrote:
>
> > how call whois information for set of domains with Perl?
>
> You should read the documentation.
>
>
> my $whois = `whois site.com`
>
> for (split '\n', qx(whois site.com)) {
>  ...
> }
>

Or better yet, use a module:

http://search.cpan.org/~dhudes/Net-Whois-1.9/Whois.pm

Matt




------------------------------

Date: Sun, 11 Apr 2004 12:17:53 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: Localised sub?
Message-Id: <c5a9mb$7t4$1@bunyip.cc.uq.edu.au>

Abigail wrote:

> }}  MAIN FOO IS CODE(0x812583c)
> }}  MAIN FOO NOW CODE(0x81232a0)
> }}  MAIN FOO NOW CODE(0x81232a0)
> }}  1...
> }}  Undefined subroutine &main::foo called at test.pl line 15.
> 
> Yes, that's because the subs are created at compile time, and at 
> runtime you localize the glob.
> 
> }}  So now I'm wondering how to access a subroutine with a 'local' name. Is it even 
> }}  possible?
> 
> Use the following in the inner block, instead of 'sub foo { ... }':
> 
>     *foo = sub {
>         print "2\n";
>         $oldfoo -> ();
>     };
> 
> Abigail

That's my new thing learnt for today - thanks :)

MB


------------------------------

Date: Sat, 10 Apr 2004 19:52:41 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: new bbs
Message-Id: <c5ad39$cqo$1@reader2.nmix.net>

http://www.infusedlight.net/robin/bbs/bbs.pl?action=view
my latest opus. I hope you like it. I'd like to see if some hacker can hack
this baby. I uses cgi.pm and is way more secure.
Admin script isn't done yet.

--
Regards,
-Robin
--
robin @ infusedlight.net




------------------------------

Date: 10 Apr 2004 22:51:05 GMT
From: ctcgag@hotmail.com
Subject: Re: Perl Timer
Message-Id: <20040410185105.211$Ws@newsreader.com>

xbg86@webtv.net (jon) wrote:
> is there a way to make a perl timer?

This is how I did it:

1) Buy a watch with a stopwatch functionality
2) Wear it until one of the straps breaks.
3) Use the other strap to hang it next to the computer display.
4) Use the stopwatch whenever you want to time a perl script.

HTH.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Sun, 11 Apr 2004 02:05:34 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: Random Qs: overloading ==; import
Message-Id: <c5a95e$kb6$1@reader1.panix.com>



I recently came across the following (somewhat tongue-in-cheek) Perl
code.

    #!/usr/bin/perl -w
    use strict;

    BEGIN
    {
      package True;

      use overload
        'eq' => \&equals,
        '==' => \&equals,
        bool => sub { !!1 },
        '!'  => sub { False->new() },
      ;

      use base 'Exporter';
      our @EXPORT = qw( &TRUE );

      sub new
      {
        my ($class) = @_;
        my $self = 1;
        return bless \$self, $class;
      }

      sub TRUE
      {
        return True->new();
      }

      sub equals
      {
        my ($x, $y, $swap) = @_;

        $y ? True->new() : False->new();
      }
    }

    BEGIN
    {
      package False;

      use overload
        'eq' => \&equals,
        '==' => \&equals,
        bool => sub { !!0 },
        '!'  => sub { True->new() },
      ;

      use base 'Exporter';
      our @EXPORT = qw( FALSE );

      sub new
      {
        my ($class) = @_;
        my $self = 0;
        return bless \$self, $class;
      }

      sub FALSE
      {
        return False->new();
      }

      sub equals
      {
        my ($x, $y, $swap) = @_;

        return $y ? False->new() : True->new();
      }
    }

    BEGIN
    {
      import True;
      import False;
    }

    my $n;
    BEGIN { $n = 0 }
    use Test;
    plan tests => $n;

    BEGIN { $n += 2 }
    ok TRUE;
    ok not FALSE;

    # several more tests omitted from the original

    __END__

I have some questions about this code:

1. Why do the equals subs have a third (unused) argument $swap?

2. In this case, what would be the difference between "import True;"
   and "use True;"?  Is "import True;" equivalent to
   "True->import();"?  And why are the import statements placed inside
   a BEGIN block?

Thanks,

kj


-- 
NOTE: In my address everything before the period is backwards.


------------------------------

Date: Sat, 10 Apr 2004 20:34:18 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Regexp guestion
Message-Id: <v8Xdc.735$37.91608@news.siol.net>

Hi!

I would like to make a regexp which would string that is
something like this

abcde abcde { abcde a b c d } abcde abcde

change into

abcde abcde {abcdeabcd} abcde abcde

Every space character between { and } should be deleted.

I have come to this:

1 while $string =~ s/({\S*?)\s(\S*?})/$1$2/g;

Is there some other (better) way (I do not like loops
which are maybe not necessary).


Mike


------------------------------

Date: 10 Apr 2004 20:52:36 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Regexp guestion
Message-Id: <ad1jy8az.fsf@online.no>

Mike Mimic <ppagee@yahoo.com> wrote:

> Every space character between { and } should be deleted.
> 
> I have come to this:
> 
> 1 while $string =~ s/({\S*?)\s(\S*?})/$1$2/g;

I'm not sure it's better, but it's an alternative

   s/ \s+ (?= [^{]* } ) //xg;

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


------------------------------

Date: Sat, 10 Apr 2004 16:40:48 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regexp guestion
Message-Id: <slrnc7gqf0.hi3.tadmc@magna.augustmail.com>

Mike Mimic <ppagee@yahoo.com> wrote:

> abcde abcde { abcde a b c d } abcde abcde
> 
> change into
> 
> abcde abcde {abcdeabcd} abcde abcde
> 
> Every space character between { and } should be deleted.
> 
> I have come to this:
> 
> 1 while $string =~ s/({\S*?)\s(\S*?})/$1$2/g;
> 
> Is there some other (better) way (I do not like loops
> which are maybe not necessary).


   s< ( { [^}]* } ) >
    < ($a = $1) =~ tr/ //d; $a >gxe;


I wouldn't call that "better" though...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 11 Apr 2004 00:30:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regexp guestion
Message-Id: <c5a3j9$l5v$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Mike Mimic <ppagee@yahoo.com> wrote:
> 
> > abcde abcde { abcde a b c d } abcde abcde
> > 
> > change into
> > 
> > abcde abcde {abcdeabcd} abcde abcde
> > 
> > Every space character between { and } should be deleted.
> > 
> > I have come to this:
> > 
> > 1 while $string =~ s/({\S*?)\s(\S*?})/$1$2/g;
> > 
> > Is there some other (better) way (I do not like loops
> > which are maybe not necessary).
> 
> 
>    s< ( { [^}]* } ) >
>     < ($a = $1) =~ tr/ //d; $a >gxe;
> 
> 
> I wouldn't call that "better" though...

It's hard...  How about this:

     s< ( { [^}]* } ) >
      < join '', split ' ', $1 >gxe;

Anno


------------------------------

Date: Sun, 11 Apr 2004 00:41:28 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Returning multiple values
Message-Id: <c5a47n$isl$1@reader1.panix.com>





I don't think I'll ever manage to learn all of Perl's little
quirks...  I just discovered that Perl has two very different ways
of returning multiple values (see below).  What's the rationale
for this ambiguous behavior?

If one defines "sub foo { (7, 8, 9) }", then "scalar foo()" evaluates
to 9.  But if one defines "sub bar { my @x = (7, 8, 9) }", then
"scalar bar()" evaluates to 3.

Is there a way to get bar's behavior without the superfluous
assignment?

The more annoying problem is when one is using some function like
foo above written by someone else, and wants to get only the number
of values returned.  Then it seems like the simplest way to do this
requires another superfluous assignment:

  my $n = (my @x = foo());

or

  my $n = do { my @x = foo() };

or

  my $n = @{[foo()]};

Is there a way to code this that is both succinct and does not
require extraneous constructs?  In other words, is there a way
(other than through a superfluous assignment) to tell perl (and
anyone reading the code) that "(7, 8, 9)" in the definition of foo
should be intepreted as an array, and not as a list?

Thanks!

jill

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



------------------------------

Date: Sun, 11 Apr 2004 01:39:01 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Returning multiple values
Message-Id: <4078A144.7050107@rochester.rr.com>

J Krugman wrote:

> I don't think I'll ever manage to learn all of Perl's little
> quirks...  I just discovered that Perl has two very different ways
> of returning multiple values (see below).  What's the rationale
> for this ambiguous behavior?


It is not ambiguous -- it is the difference between the behavior 
exhibited by the comma operator and that exhibited by an array.  See:

    perldoc -q "list and an array"

or

    perldoc -q 'list and an array'

depending upon your OS.


> 
> If one defines "sub foo { (7, 8, 9) }", then "scalar foo()" evaluates
> to 9.  But if one defines "sub bar { my @x = (7, 8, 9) }", then
> "scalar bar()" evaluates to 3.


The first is because scalar (7,8,9) applies the comma operator, 
returning in each case the rightmost of the values on the two sides of 
each comma.  When you say scalar (@x), it returns the number of elements 
in array @x.  Two vastly different cases.


> 
> Is there a way to get bar's behavior without the superfluous
> assignment?

> 
> The more annoying problem is when one is using some function like
> foo above written by someone else, and wants to get only the number
> of values returned.  Then it seems like the simplest way to do this
> requires another superfluous assignment:
> 
>   my $n = (my @x = foo());
> 
> or
> 
>   my $n = do { my @x = foo() };
> 
> or
> 
>   my $n = @{[foo()]};


Try:

     my $n=()=foo();


> 
> Is there a way to code this that is both succinct and does not
> require extraneous constructs?  In other words, is there a way
> (other than through a superfluous assignment) to tell perl (and
> anyone reading the code) that "(7, 8, 9)" in the definition of foo
> should be intepreted as an array, and not as a list?

 >

> jill

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Sun, 11 Apr 2004 02:37:39 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Returning multiple values
Message-Id: <c5ab1j$l0a$1@reader1.panix.com>



In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:

>J Krugman wrote:
>> The more annoying problem is when one is using some function like
>> foo above written by someone else, and wants to get only the number
>> of values returned.  Then it seems like the simplest way to do this
>> requires another superfluous assignment:
>> 
>>   my $n = (my @x = foo());
>> 
>> or
>> 
>>   my $n = do { my @x = foo() };
>> 
>> or
>> 
>>   my $n = @{[foo()]};


>Try:

>     my $n=()=foo();


OK, but what does it mean?  What does perl do when it executes the
statement

  () = (7, 8, 9);

?  Does the above evaluate to some sort of anonymous array?

Thanks,

jill

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



------------------------------

Date: Sun, 11 Apr 2004 03:09:19 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Returning multiple values
Message-Id: <4078B667.4050005@rochester.rr.com>

J Krugman wrote:

> In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
> 
> 
>>J Krugman wrote:
 ... 
> OK, but what does it mean?  What does perl do when it executes the
> statement
> 
>   () = (7, 8, 9);

> 
> ?  Does the above evaluate to some sort of anonymous array?


Look it up:

     perldoc perldata

in the "List value constructors" section.


> jill

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Sun, 11 Apr 2004 03:53:40 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Returning multiple values
Message-Id: <c5afg4$m9d$1@reader1.panix.com>

In <4078B667.4050005@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:

>J Krugman wrote:

>> In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>> 
>> 
>>>J Krugman wrote:
>... 
>> OK, but what does it mean?  What does perl do when it executes the
>> statement
>> 
>>   () = (7, 8, 9);

>> 
>> ?  Does the above evaluate to some sort of anonymous array?


>Look it up:

>     perldoc perldata

>in the "List value constructors" section.

OK, I read that section, but it says nothing whatsoever about
assigning to ().

Does anybody know what Perl does when one assigns a list to () (as
shown above)?

Thanks,

jill

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



------------------------------

Date: Sat, 10 Apr 2004 18:06:43 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Tests fail in cpan, succeed manually
Message-Id: <c59d3j$bk3$1@reader1.panix.com>

In <pan.2004.04.10.16.24.30.113130@remove.adelphia.net> James Willmore <jwillmore@remove.adelphia.net> writes:

>On Sat, 10 Apr 2004 15:42:05 +0000, J Krugman wrote:
>> I'm trying to understand what's going on, and decide what to do. When I
>> attemptto install the module XML::Validator::Schema via CPAN.pm, all
>> attempted tests fail:
>> 
>> Failed Test Status Wstat Total Fail  Failed  List of Failed
>>
>> --------------------------------------------------------------------------------
>> t/01basic.t>                    2    2 100.00%  1-2 
>> t/02yaml.t                     152 152 100.00%  1-152 
>> t/03types.t                   163  163 100.00%  1-163
>> t/04model.t                   38   38 100.00%  1-38 2 tests skipped.
>> Failed 4/6 test scripts, 33.33% okay. 355/355 subtests failed, 0.00%
>> okay. make: *** [test_dynamic] Error 29
>>   /usr/bin/make test -- NOT OK
>> Running make install
>>   make test had returned bad status, won't install without force
>> 
>> But when I run these tests "by hand" (e.g. in the build directory, perl
>> -Mlib='./blib/lib' t/01basic.t), they *all* succeed.
>> 
>> This is a very unusual situation.  My installations via CPAN.pm
>> typically succeed, and if they fail because of some failed test, this
>> test fails also when invoked manually.
>> 
>> Can someone tell me why these tests would fail when invoked through
>> CPAN.pm, but not when they are invoked manually?  And should I disregard
>> CPAN.pm's warnings in this case and force the installation?

>Some modules respond well to (when making by hand):
> make test TEST_VERBOSE=1

>This, if the module is willing, will produce verbose output that *may*
>help you make this decision.

This helped, but I'm not quite there yet.  I discovered that the
problem is not with CPAN.pm.  If I run

  make test

outside of the cpan shell, I get the same failure messages, but if
I run the tests individually (as described above) they all succeed.

When I ran

  make test TEST_VERBOSE=1

as you suggested, I discovered that all the subtests succeed, but
somehow make (or something else) declares these tests failed.  For
example:

t/01basic...........ok 1 - use XML::Validator::Schema;
ok 2
1..2
FAILED tests 1-2
        Failed 2/2 tests, 0.00% okay

 ...and so on for every test in t.  Does anyone have any guesses as to
why these tests are being incorrectly classified as failures?

I have a hunch that the problem has something to do with the fact
that these tests use Test::More instead of Test, but I don't know
enough about Test::More to know for sure whether this is the case,
or whether the problem is in Test::More or in how it is being used
by the author of the failing tests.

BTW, I tried reporting a bug about the XML::Validator::Schema
installation at http://rt.cpan.org (per instructions in the
XML::Validator::Schema man page), but I get a very strange error
message to the effect that the site is down (the error message is
strange because it gives no indication that the requested page has
anything to do with Perl or CPAN).  *sigh*

It looks like I'm standing on a mountain of bugs...

It is ironic that someone who bothered to set up a test suite for
his/her module, did not bother to make sure that the installation
itself was bug-free...

At times like these I wonder about the future of open software.
It's not like I'm not doing my part.  I devote most of my paid and
spare time to coding free, open software products...  But I spend
an inordinate amount of time, far too much, chasing and reporting
bugs...  Sorry, but it really pisses me off.

Maybe open the software paradigm is not such a good idea after all.
True, paid software can be very buggy, and those who sell software
(notably Microsoft) seem to be able to get away with murder in this
respect, but with the paid software model at least there is a
*possibility* that in the future those selling buggy software will
be held accountable.  With free software even that slim hope is
out of the question.

jill
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



------------------------------

Date: 10 Apr 2004 18:54:59 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Tests fail in cpan, succeed manually
Message-Id: <196cb7af.0404101754.542e0d3f@posting.google.com>

J Krugman <jkrugman@yahbitoo.com> wrote in message news:<c59d3j$bk3$1@reader1.panix.com>...
> In <pan.2004.04.10.16.24.30.113130@remove.adelphia.net> James Willmore <jwillmore@remove.adelphia.net> writes:
> 
> >On Sat, 10 Apr 2004 15:42:05 +0000, J Krugman wrote:
> >> I'm trying to understand what's going on, and decide what to do. When I
> >> attemptto install the module XML::Validator::Schema via CPAN.pm, all
> >> attempted tests fail:
> >> 
The module's author recommends this mailing list for support:

http://listserv.activestate.com/mailman/listinfo/perl-xml

Have you tried that yet?

Jim Keenan


------------------------------

Date: 10 Apr 2004 19:13:54 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Tests fail in cpan, succeed manually
Message-Id: <196cb7af.0404101813.3ad74b9a@posting.google.com>

J Krugman <jkrugman@yahbitoo.com> wrote in message news:<c59d3j$bk3$1@reader1.panix.com>...
> In <pan.2004.04.10.16.24.30.113130@remove.adelphia.net> James Willmore <jwillmore@remove.adelphia.net> writes:
> 
> >On Sat, 10 Apr 2004 15:42:05 +0000, J Krugman wrote:
> >> I'm trying to understand what's going on, and decide what to do. When I
> >> attemptto install the module XML::Validator::Schema via CPAN.pm, all
> >> attempted tests fail:
> >> 
For the heck of it, I decided to try to install this module via the
CPAN shell.  I was not anticipating good results, because the box on
which I was installing it is Windows98, Perl 5.6.1 only -- and in the
past, whenever I have tried to install a module with many
prerequisites such as this one, my system has gagged.  And since I had
few of the prereqs installed, the installation took nearly 10 minutes.
 At least 5 different prereqs had to be installed before the shell got
to this module.

However, it worked.  All the tests passed and XML::Validator::Schema
was installed.  So I haven't been able to reproduce your problem. 
Sorry.

Jim Keenan


------------------------------

Date: Sat, 10 Apr 2004 23:34:12 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: The value of Truth
Message-Id: <c5a09k$hmb$1@reader1.panix.com>




The if procedure Test::ok is given 3 arguments, it evaluates the
first 2 arguments, tests to see if they are equal (using eq), and
prints a message involving the 3rd argument if they are not.

Supposing that we wanted a test that succeeded if foo() > 0, and
having the message upon failure contain the string "bad foo".  One
could use something like ok(foo() > 0, 1, 'bad foo'), on the
assumption that if foo() > 0 was true it would evaluate to 1.

I remember reading somewhere that it was bad form to assume any
particular value for a truth value in Perl, because the implementation
reserved the right to change this value.

But I don't remember whether one could assume that whatever truth
value a Perl implementation used, it would be *consistent*.  For
example, can one assume that the expression ((1 > 0) eq (1 > 0))
will always evaluate to true?  Assuming that this is the case,
to code the test above one could write something like this

  ok(foo() > 0, !!1, 'bad foo')

Are expressions such as !!1 and !1 (or !!2 and !3, etc.) the best
way in Perl to code true and false values in an implementation-independent
way?

Thanks,

kj





-- 
NOTE: In my address everything before the period is backwards.


------------------------------

Date: Sat, 10 Apr 2004 22:13:02 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: The value of Truth
Message-Id: <pan.2004.04.11.02.12.57.89346@remove.adelphia.net>

On Sat, 10 Apr 2004 23:34:12 +0000, kj wrote:

> The if procedure Test::ok is given 3 arguments, it evaluates the first 2
> arguments, tests to see if they are equal (using eq), and prints a
> message involving the 3rd argument if they are not.
> 
> Supposing that we wanted a test that succeeded if foo() > 0, and having
> the message upon failure contain the string "bad foo".  One could use
> something like ok(foo() > 0, 1, 'bad foo'), on the assumption that if
> foo() > 0 was true it would evaluate to 1.

In this case, I'd just code ...
ok(foo(), 1, 'bad foo');

If foo() can only return '0' or '1', then a return value of '1' would
cause the test to pass.  I don't see the point of going to any great
lengths to evaluate foo() it it only returns one of two values.  It's
either true (1) or false (0).
 
> I remember reading somewhere that it was bad form to assume any
> particular value for a truth value in Perl, because the implementation
> reserved the right to change this value.

Not sure where you got that.  Logically, there is only one way to evaluate
truth.  The issue of evaluating truth comes in when programmers don't
follow laws of logic in the code (such as DeMorgan's Law).  *Some*
functions/methods don't follow a pre-conceived notion of "truth" (they
return "undef" upon failure versus "true" or "false").  Again, this is the
programmer, not the language :-)

A subtle yet important example of what newbie programmers do is ignore
precedence.  Consider the following code: ($foo && $bar && $fubar)

is different from
(($foo && $bar) && $fubar)

Both evaluate "truth" differently, but *may* arrive at the same
conclusion.  If they arrive at the same conclusion once, then the newbie
will go and think that it's always this way, code something similar, then
ask "Why doesn't *this* work?".  The answer is precedence :-)  According
to logic (subset of mathmatics), they are different statements of truth.
The issue in the above case is the programmer, not the language.  The
language will do the logical thing.
 
> But I don't remember whether one could assume that whatever truth value
> a Perl implementation used, it would be *consistent*.  For example, can
> one assume that the expression ((1 > 0) eq (1 > 0)) will always evaluate
> to true?  Assuming that this is the case, to code the test above one
> could write something like this
> 
>   ok(foo() > 0, !!1, 'bad foo')
> 
> Are expressions such as !!1 and !1 (or !!2 and !3, etc.) the best way in
> Perl to code true and false values in an implementation-independent way?

The example
((1 > 0) eq (1 > 0))

will *always* be true.  It's a mathmatical (and logical :-) ) truth.
However, why would one want to code
ok(foo() > 0, !!1, 'bad foo')

Unless this were an exercise in logic (meaning, one were evaluating truth
tables instead of crunching financial data), I wouldn't code like that. 
It breaks the basic idea of "coding positive".  I try to stay away from
code like

if(!$foo){
 ...
}

and instead write

unless($foo){
 ...
}

or code in such a way that evaluating $foo doesn't enter into the picture.
 Not always practical or possible, but still a good direction to head :-) 
 It's less code and there's no mistaking what you're trying to do.  As
soon as you use some evaluation of "false" (!$foo), there's *always* going
to be someone who's not going to understand what you were trying to do.
It's subtle, I know.  But since Perl has 'unless', I'm going to use it :-)
 Now, if this were another langauge (like COBOL), I'd still try to avoid
 the idea of
using some "false" evaluation.  It's easier to see "true" than "false" :-)

The code you write is *not* for you, but the next person who is going to
maintain the code.  If someone else can't follow what you wrote, be sure
that one year from now not even you will be able to follow what's going on
:-)

Just my $0.02 :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 Office Automation, n.:  The use of computers to improve
 efficiency by removing anyone you would want to talk with over
 coffee. 


------------------------------

Date: 10 Apr 2004 16:40:59 -0700
From: fxn@hashref.com (Xavier Noria)
Subject: Why are arrays and hashes this way?
Message-Id: <31a13074.0404101540.504a23e6@posting.google.com>

When I introduce references the first thing I mention is that they
allow us to build nested structures. However, the importance of that
feature is a consequence of the fact that structures cannot be nested
themselves.

Does anybody know why structures were designed so that they could just
hold scalars?

-- fxn


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6384
***************************************


home help back first fref pref prev next nref lref last post