in reply to Re: Difficulties with split
in thread Difficulties with split
A full stop is a regular expression metacharacter meaning match any character (with caveats, see perlretut, perlre). However, a backslash escapes the special meaning of a metacharacter so that \. matches a literal full stop. That means you are spliting on two literal full stops, which is not quite what was wanted.
$ perl -le ' > $in = q{abcdefg}; > @vals = split m{\.\.}, $in; > print for @vals;' abcdefg $ perl -le ' > $in = q{abc..defg}; > @vals = split m{\.\.}, $in; > print for @vals;' abc defg $
I hope this is of interest.
Cheers,
JohnGG
|
|---|