On Feb 22, 2006, at 21:08, Bowen, Bruce wrote:

Thanks, I'm running under Windows XP. It's strange that with the exact same file where it system can't find the index /\n or "/\n" it has no problem finding that when used with the split command. Many people have indicated that the index should work, but all I get when I print out the $a is -1.

This is more a question of is this the way it should be or should this be considered a bug. In fact after careful review of my code, using the split method gave much better results with way shorter code.

I have not followed the thread in detail but the point is:

"\n" in Windows XP is exactly "\012". When a text file has the conventions of Windows and your line-oriented script is running in Windows (not in Cygwin) you don't see pairs CRLF in the script, you see just "\012"s.

Now in the examples you sent the split was on the regexp /\n/, whereas the index is on "/\n". You shouldn't expect them to do the same because the latter requires a slash before the newline, whereas the former only splits on newlines, with no additional constraint.

You seem to assume /\n/ in the first example carries the initial slash, but it doesn't, the regexp has only one character, which in your marchine is exactly "\012". Both slashes are delimiters, they are not part of the regexp itself.

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to