And we're back to the original question (answered here): You're missing use utf8;.

Also, you should be using sprintf "%vX", $_ instead of unpack "H*", $_. The former handles any strings. The latter only handles strings of bytes (strings where the characters are no higher than 0xFF), so it's definitely inappropriate here.

#!/usr/bin/perl

use v5.36;
use warnings;

# Source code encoded using UTF-8.
use utf8;

# Terminal provides/expects UTF-8 (for `say`).
use open ":std", ":encoding(UTF-8)"; 

use Encode qw( decode_utf8 );

my $base = "Screenshot-2024-02-23-at-1.05.14\x{202F}AM.png";
my $lit  = "Screenshot-2024-02-23-at-1.05.14 AM.png";

my @files = map { decode_utf8 $_ } glob( "*" );
my ( $file ) = grep { /^Screenshot-2024-02-23-at-1.05.14\s/ } @files;

my $base_hex = sprintf "%vX", $hex;

for ( $base, $lit, $file ) {
   say $_;
   say $_ eq $base ? "same" : "different";

   my $hex = sprintf "%vX", $_;
   say $hex;
   say $hex eq $base_hex ? "same" : "different";
}

Output:

Screenshot-2024-02-23-at-1.05.14 AM.png
same
53.63.72.65.65.6E.73.68.6F.74.2D.32.30.32.34.2D.30.32.2D.32.33.2D.61.74.2D.31.2E.30.35.2E.31.34.202F.41.4D.2E.70.6E.67
same
Screenshot-2024-02-23-at-1.05.14 AM.png
same
53.63.72.65.65.6E.73.68.6F.74.2D.32.30.32.34.2D.30.32.2D.32.33.2D.61.74.2D.31.2E.30.35.2E.31.34.202F.41.4D.2E.70.6E.67
same
Screenshot-2024-02-23-at-1.05.14 AM.png
same
53.63.72.65.65.6E.73.68.6F.74.2D.32.30.32.34.2D.30.32.2D.32.33.2D.61.74.2D.31.2E.30.35.2E.31.34.202F.41.4D.2E.70.6E.67
same

In reply to Re^10: Any good ways to handle NARROW NO-BREAK SPACE characters in regex in newer versions of Perl? by ikegami
in thread Any good ways to handle NARROW NO-BREAK SPACE characters in regex in newer versions of Perl? by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.