Why is the # character considered a word character in Perl? Or I don’t understand how this code should work?
my $filename = "Something_with_#_sign.jpg";
$filename =~ s/ # substitute...
[^ # characters which are NOT:
\w # "word" characters
] # end of character classes
/_/xg;
print "$filename\n";
Productivity:
Something_with_#_sign.jpg
I would expect the # sign to be replaced by the _ symbol (underscore).
source
share