|
 
Mucking around with pos() beforehand makes them behave differently.
#!/usr/bin/perl -wT
use strict;
$_ = 'abcdefg';
pos($_) = 3; # <= this modifies the regex but not the split
my @split = split //;
my @regex = /./gs;
print "S:$_\n" for @split;
print "\n";
print "R:$_\n" for @regex;
=OUTPUT
S:a
S:b
S:c
S:d
S:e
S:f
S:g
R:d
R:e
R:f
R:g
|