0

I am getting the following errors when running the code:

syntax error line 5, near "use Digest::MD5

sub makeKey 
"
syntax error at line 8, near "}"
syntax error at line 15, near ")
}"
Execution aborted due to compilation errors.

My script:

use lib '/home/me/Desktop/pm/MD5.pm';
use Digest::MD5

sub makeKey 
{
    my ($strPassword, $strRndk);
    $strKey = uc(md5Hash($strPassword)) + $strRndk + "Y(02.>'H}t\":E1" + md5Hash($strKey);
    return $strKey;
}

sub md5Hash 
{
    my ($strPassword);
    $strMd5 = md5_hex($strPassword);
    return substr($strMd5, 16, 16) + substr($strMd5, 0, 16);
}

makeKey('test', '1A2B3C');

2 Answers 2

4

Use Digest::MDd5 needs to end with a semicolon.

Sign up to request clarification or add additional context in comments.

1 Comment

I did that, but now I get "Parameter to use lib must be directory, not file on line 1", so I did that, and now I get "Undefined subroutine &main::md5_hex called on line 14".
4

Concerning your third (and final?) problem:

"Undefined subroutine &main::md5_hex called on line 14"

Digest::MD5 doesn't export md5_hex (or anything else) by default, you have to explicitly tell it that it should export md5_hex:

use Digest::MD5 qw(md5_hex);

or use the full Digest::MD5::md5_hex name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.