On Thu, Jan 08, 2009 at 07:12:03PM -0500, Chas. Owens wrote:
> On Thu, Jan 8, 2009 at 17:47, root <mike.j...@nethere.com> wrote:
> >    The following script gives me confusing results.
> > I've not delved into OOP before and am surprised when something
> > appears to work but gives wrong answers.
> >    Explicitly Digest::MD5's md5_hex gives wrong answers if called as
> > Digest::MD5->md5_hex. OK, I've figured out that it shouldn't be called
> > like that after the fact but am surprised that it appeared to work,
> > throwing no warnings or errors.
> snip
> 
> It is giving the right answer.  You are asking the wrong question.

    Been doing that for nearly three generations, guess I'm in a rut.

> Module->method($arg) is roughly equivalent to Module::method('Module',
> $arg).  What you are seeing is the md5sum of 'Digest::MD5'.
> 
> -- 
> Chas. Owens
> wonkden.net

root@/deb40a:~/perl.practice> md5sum md5_hex; ./md5_hex md5_hex; 
    ./md5_hex -d md5_hex; ./md5_hex -o md5_hex
a8e4ced09019bd49c99f7055f945217e  md5_hex
a8e4ced09019bd49c99f7055f945217e  md5_hex
0a6d905d107f66db0089742efe2f5bd3  md5_hex
a8e4ced09019bd49c99f7055f945217e  md5_hex

root@/deb40a:~/perl.practice> for f in 
    /usr/lib/perl/5.8.8/auto/Digest/MD5/MD5.{bs,so} 
        /usr/lib/perl/5.8.8/Digest/MD5.pm; 
            do md5sum $f; done
d41d8cd98f00b204e9800998ecf8427e  /usr/lib/perl/5.8.8/auto/Digest/MD5/MD5.bs
c925d587e8a2292364d843550ac4c553  /usr/lib/perl/5.8.8/auto/Digest/MD5/MD5.so
77503ff007841a671275fdf544dad68e  /usr/lib/perl/5.8.8/Digest/MD5.pm

root@/deb40a:~/perl.practice> for f in 
    /usr/lib/perl/5.8.8/auto/Digest/MD5/MD5.{bs,so} 
        /usr/lib/perl/5.8.8/Digest/MD5.pm; 
            do cat $f md5_hex > t; md5sum t; done
a8e4ced09019bd49c99f7055f945217e  t
ca25b24aaa79399bb0f43d48e892ec6b  t
f0743567a3e4d9df350dd85a44229063  t

Chas,
    I appreciate your taking the time to respond and having been
reading your responses for several months now have no doubt that
you know what you're talking about.
    I'm still not clear however about what's going on. 
    As you can see from the above calculations what's being returned 
by Digest::MD5->md5_hex is neither the md5 sum of the module nor the 
concatenation of the module and the argument (my file md5_hex).
    Would you mind explaining further or pointing me to further reading
that might straighten out this feeble old mind?

> The most important skill a programmer can have is the ability to read.

    I can read it's just that it don't always stick the first two or three 
times when I'm takin' on something new.

Thanks again,
Mike

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to