use String::ShellQuote qw( shell_quote ); sub perl_quote { qq{"\Q$_[0]\E"} } my $email_lit = perl_quote( $email ); my @cmd = ( "perl", "-MDigest::SHA=sha256_hex", "-e", "print sha256_hex( $email_lit )", $email, ); my $cmd = shell_quote( @cmd ); my $email_SHA256 = qx($cmd); die "Can't spawn child: $!\n" if $? == -1; die "Child killed by signal ".( $? & 0x7F )."\n" ) if $? & 0x7F; die "Child exited with error ".( $? >> 8 )."\n" ) if $? >> 8;