A
Allan M. Due
Hi Folks,
Can someone clear up my misunderstanding of the match operator. I don't
understand why the following occurs. First script:
-----
use strict;
my $string = 'one1 blather one2 blather blather one3 One4';
my @array;
if ($string =~ m/one\d+/gis) {
(@array) = $string =~ m/one\d+/gis;
}
print "@array";
------
produces:
one2 one3 One4
I expected the one1 to be there but it isn't
If change the if line so there is no g
-------
use strict;
my $string = 'one1 blather one2 blather blather one3 One4';
my @array;
if ($string =~ m/one\d+/is) {
(@array) = $string =~ m/one\d+/gis;
}
print "@array";
--------
I get:
one1 one2 one3 One4
Why does the first not capture one1 into @array?
I've read the docs but the reason completely eludes me.
TIA
AmD
Can someone clear up my misunderstanding of the match operator. I don't
understand why the following occurs. First script:
-----
use strict;
my $string = 'one1 blather one2 blather blather one3 One4';
my @array;
if ($string =~ m/one\d+/gis) {
(@array) = $string =~ m/one\d+/gis;
}
print "@array";
------
produces:
one2 one3 One4
I expected the one1 to be there but it isn't
If change the if line so there is no g
-------
use strict;
my $string = 'one1 blather one2 blather blather one3 One4';
my @array;
if ($string =~ m/one\d+/is) {
(@array) = $string =~ m/one\d+/gis;
}
print "@array";
--------
I get:
one1 one2 one3 One4
Why does the first not capture one1 into @array?
I've read the docs but the reason completely eludes me.
TIA
AmD