in reply to Escape character being escaped in array push

Because the text in the file is not a newline character. It's a backslash plus the character "n".

When you use Data::Dumper to print out a variable, it tries to escape all characters that need escaping to make it a valid string usable in Perl source code. As a Backslash would be used in a string as escape character, it needs escaping (double backslash), in order to produce a string that represents the original text (e.g. a backslash and the character "n").

You can check this with a hex editor (or "hexdump -C" on Linux) on the original text file.

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Replies are listed 'Best First'.
Re^2: Escape character being escaped in array push
by mdunnbass (Monk) on Apr 05, 2022 at 00:11 UTC

    Oh my god, I'm such an idiot.

    Thank you. My confusion was a cross between this brain fart and forgetting how to properly use the find and replace all in BBEdit. Oof. Thanks for the memory jolt.