[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Troubles while using m/\G/ g...



(Using MacPerl 5.1.4r4 on 68K Mac)

On the way of learning Perl,
I wanted to know more about regexp's in combination with /g, and
tried the following example from an 5.004 perlop page;



# using m//g with \G
$_ = "ppooqppq";
while ($i++ < 2) {
    print "1: '";
    print $1 while /(o)/g; print "', pos=", pos, "\n";
    print "2: '";
    print $1 if /\G(q)/;   print "', pos=", pos, "\n";
    print "3: '";
    print $1 while /(p)/g; print "', pos=", pos, "\n";
}

The example should print:
 
 
1: 'oo', pos=4
2: 'q', pos=4
3: 'pp', pos=7
1: '', pos=7
2: 'q', pos=7
3: '', pos=7

But it prints:

1: 'oo', pos=
2: '', pos=
3: 'pppp', pos=
1: 'oo', pos=
2: '', pos=
3: 'pppp', pos=

So it seems that pos is unknown to MacPerl?

The perlop/perlre pages also states that \G and //g can be 
used one or the other; which differs from the doc for MacPerl
that both should be used together.

Am I doing something wrong?
Am I perhaps reading documentation that is not valid for 
this version of MacPerl?

Gert Kok
Faculty of Human Movement Sciences
Vrije Universiteit Amsterdam
The Netherlands

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch