regex matching statements

[email protected] (Jeff Peng via beginners) Wed, 19 Jun 2024 09:55:25 +0800
Newsgroups perl.beginners
Message-ID <[email protected]>
Hello list,

are these statements the same in perl?

$ perl -le '$_="abc";if (!/\w+\d+/){print "not matched"}'
not matched

$ perl -le '$_="abc";if ($_ !~ /\w+\d+/){print "not matched"}'
not matched

or which is the better one?

Thanks.