How to do same as perl's crypt?

in linux type:
$ openssl passwd ruby
get the encrypted string ‘2z8GoTY1O2T3A’, and paste to the followed perl

$encrypted_password = “2z8GoTY1O2T3A”;
$input = $ARGV[0];
if (crypt($input,$encrypted_password) eq $encrypted_password) {
print “Correct password!\n”;
else {
print “Access Denied\n”;

when “perl ruby”, get
Correct password!

whe “perl otherword”, get
Access Denied

how to compare the input string is in accordance with the encrypted
string with ruby as same as perl?