open(FILE, 'C:\Users\li\perl\animals.txt'); my @patterns = ( qr/((\d)+)/, qr/((?<=#)(.*?)(?= fin))/); if( $string ~~ @patterns ) { print "$1\n"; };