in reply to Re: Newbie doesn't understand Digest::MD5
in thread Newbie doesn't understand Digest::MD5

Thanks for your help, I've just tried but binary mode doesn't change anything, but testing with string without @ charcter jhondoe:one_real:jhondoe gives a good result !
echo -n "jhondoe:one_real:jhondoe" | perl computedigest.pl a20d2f25a66afc8db3befa1b4aca4d14 a20d2f25a66afc8db3befa1b4aca4d14
Can it be a charcter issue? eltorio

Replies are listed 'Best First'.
Re^3: Newbie doesn't understand Digest::MD5
by Corion (Patriarch) on Apr 19, 2006 at 12:43 UTC

    Yeouch - I didn't spot that error. You're running your code without use strict; and use warnings;, and either of them would have alerted you (and me) to what actually went wrong:

    Perl interpreted the @ondoe in your string as an array variable. That array variable isn't used and hence is empty. You need to use single quotes to prevent variable interpolation by Perl.

    Also, you should really start using warnings and strict, as they prevent typos from growing into hidden, hard to track down bugs.

      Thank you !!!! It works well. My error was double quote in place of simple quotes, starting now i'll always use
      use strict; use warnings;
      because it gives an explicit message.
        Two quick notes since you've described yourself as a newbie.

        Some folks like to omit the "use warnings" in production code since the errors sometimes give up too much information to users who, if they are bad guys, can use it maliciously. But during development and testing it's pretty essential.

        Also, if you are going to be taking input from users, you should seriously consider turning on taint mode with the -T option. It's beyond the scope here to explain how to untaint data. The perlsec document has info about that and a whole lot more.