in reply to Re^4: Perl SHA256
in thread Perl SHA256

Hi Hippo.. Your command works fine on the command line.. I can't get it to work in the perl script using a variable for the email.. If I assign your example exactly it works fine.. But if I try to use a variable for a literal email it fails despite everything I've tried to make it work.. I've even tried to build a concatenated string or use substitution to replace a dummy "EMAIL" with actual value.. I've tried every Google search I can think of.. Any suggestions?

This example works fine $SENDVAR1 = q(perl -MDigest::SHA=sha256_hex -E 'say sha256_hex(q/XXXX/ +)'); my $email_SHA256 = print qx($SENDVAR1); This doesn't work: $SENDVAR1 = q(perl -MDigest::SHA=sha256_hex -E 'say sha256_hex(q/$EMAI +L_IN/)'); my $email_SHA256 = print qx($SENDVAR1);

Replies are listed 'Best First'.
Re^6: Perl SHA256
by marto (Cardinal) on Feb 15, 2023 at 12:47 UTC

    Why are you shelling out and running a command line when you can just use the module within your code?

    #!/usr/bin/perl use strict; use warnings; use Digest::SHA qw(sha256_hex); my $email = 'test@example.com'; my $email_sha256 = sha256_hex( $email ); print "$email_sha256\n";
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^6: Perl SHA256
by soonix (Chancellor) on Feb 15, 2023 at 12:48 UTC
    I think this tutorial page from szabgab's website will be helpful for you.
    q/$EMAIL_IN/ is a string consisting of a dollar sign, capital letter E, capital letter M, etc. That's probably not what you want.