[Solved] How set found text in variable in Perl


Use captures ((...)).

if ( my ($capture) = $x =~ /(NY)/ ) {
    say $capture;
}

By the way, always use use strict; use warnings qw( all );.

The above program also needs use feature qw( say );.

solved How set found text in variable in Perl