my $x = "1234"; my @X = ($x =~ /(#)?/)[1,3]; say scalar @X; # defined(@X) is deprecated say "Matched" if $x =~ /(#)?/; __END__ 0 Matched