in reply to Re^2: double quote vs single quote oddities. I need enlightenment
in thread double quote vs single quote oddities. I need enlightenment
So what you said makes sense for me up until the single quote doubled escaped
For the expression split "\\.", 'data.txt', first Perl interpolates "\\." to the literal string [\.]. This string is then fed to the regular expression engine, making split "\\.", 'data.txt' equivalent to split /\./, 'data.txt'. The input is split on literal periods and then result is then ('data','txt').
why doesn't split bust the expression apart into NULL and ata1.txt
You would get your expected result if you include a limit on the expression, i.e. split /./, $foo, 2;. Unless an explicit limit is included, split will operate on every match. Therefore, the initial result of the split is a list of nine empty strings. As documented in split,
empty trailing ones are deleted. (If all fields are empty, they are considered to be trailing.)
Therefore, it returns an empty list.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: double quote vs single quote oddities. I need enlightenment
by lyapunov (Novice) on Jul 08, 2010 at 18:05 UTC | |
by furry_marmot (Pilgrim) on Jul 08, 2010 at 18:27 UTC |