in reply to Re^2: In my it is printing in the else i want to get output for the for loop in linux.
in thread In my it is printing in the else i want to get output for the for loop in linux.
No matter what, the OP's code is bizarre.use strict; use warnings; my $x = 'a34x5'; my @y = $x =~ /([\d]+)/g; my @z = $x =~ /([0-9]+)/g; print "@y\n"; # 34 5 \d worked fine print "@z\n"; # 34 5 my @b = $x =~ /([\d\w]+)/g; print "@b\n"; # a34x5 \d irrelevant but \w works my @c = $x =~ /([\w]+)/g; #brackets not needed print "@c\n"; #a34x5 my @d = $x =~ /(\w+)/g; print "@d\n"; #a34x5
Added: The idea of using an anchor to the beginning of the string, followed by any amount of random stuff, makes no sense to me. Better to leave that off entirely (don't put /^.*(match)/, just put /(match)/.
I think if you want \ in the character set, you have to escape it with another \
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: In my it is printing in the else i want to get output for the for loop in linux.
by afoken (Chancellor) on Mar 29, 2022 at 11:19 UTC | |
by hippo (Archbishop) on Mar 29, 2022 at 12:14 UTC |