Hello, I tried to combine the inner while loops into one loop but it doesn't work. It goes into infinite loop
#!/usr/bin/perl use strict; use warnings; my $d = qr/\d/; #number my $a = qr/[a-c]+/; #alpha while (<DATA>) { #while ( /($a)/g ) { # print "$1\n"; #} while ( /($a)/g || /($d)/g ) { #<----won't work #while ( /($d)/g ) { print "$1\n"; } } __DATA__ 1 a 2 aa 3 aaa 4 b 5 bb 6 bbb 7 c 8 cc 9 ccc
Original content restored above by GrandFather
nevermind I fixed it already
while ( /($a|$d)/g ) {
In reply to while loop with logical or by perlkiller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |