The 2 cats and the dog.
The 8 cats and the 6 dogs.
The 3 pigs and the 2 sheep.
#story fin #cats and dogs fin #sheep fin
####
2
8
6
3
2
story
cats and dogs
sheep
####
open(FILE, 'C:\Users\li\perl\animals.txt');
$/ = " ";
while () {
if (m/((\d)+?)|((?<=#)(.*?)(?= fin))/g) {
print "$1\n";
}
}
####
open(FILE, 'C:\Users\li\perl\animals.txt');
$/ = " ";
while () {
if (m/(?=.*((\d)+?))(?=.*((?<=#)(.*?)(?= fin)))/g) {
print "$1\n";
}
}
####
open(FILE, 'C:\Users\li\perl\animals.txt');
my @patterns = ( qr/((\d)+)/, qr/((?<=#)(.*?)(?= fin))/);
if( $string ~~ @patterns ) {
print "$1\n";
};