in reply to Single Quote string with Variable

The way you are going about this (shelling out from perl to run perl) is not only crazy and inefficient but it's also unmaintainable as you are currently finding out. Here's the answer to your question but don't you ever write code like this for any real purpose.

use strict; use warnings; use Test::More tests => 1; my $want = 'aa9957b8d673c62eb1e836cbfcf09719ca41e6e3bf960bba98e74289b8 +8b66fb'; my $email = 'BOK_NEPA@hotmail.com'; # XXX Really awful horrible code to test starts here my $SENDVAR1 = qq(perl -MDigest::SHA=sha256_hex -E 'say sha256_hex(q/$ +email/)'); my $email_SHA256 = qx($SENDVAR1); # XXX Really awful horrible code to test ends here chomp $email_SHA256; diag "Command is >$SENDVAR1<"; is $email_SHA256, $want;

See also How to ask better questions using Test::More and sample data and the Basic debugging checklist.


🦛

Replies are listed 'Best First'.
Re^2: Single Quote string with Variable
by ikegami (Patriarch) on Feb 15, 2023 at 21:40 UTC

    Please stop making such awful suggestions. Why would show show someone how to include code injection bugs?!

      you didn't actually read the text did you?

        If you think those comments change anything, you're pretty naive.