Why does Perl warn in this case
Use of uninitialized value `$new` in substitution (s///) at ./perl.pl line 8.
and not
Use of uninitialized value `$string` in substitution (s///) at ./perl.pl line 8.
#!/usr/bin/env perl
use warnings;
use strict;
my $string;
my $new;
( $new = $string ) =~ s/^.//;
$stringis not involved in the substitution. It’s on the RHS of an assignment, and having an undefined value on the RHS of an assignment shouldn’t trigger a warning.If it’s ok for
$newto be undefined, you could use