in reply to Re^4: Substitution in range operator
in thread Substitution in range operator

I'm not sure if it is an issue with the Perl version (I am using 5.16.3 and 5.22), but rather with line endings on Windows. I don't use Windows myself, but there are considerations with line-endings on that platform; do a search and you'll find at least a couple of discussions about the topic in the last couple of months.

What happens if you change the key line to:

$txt =~ s/\r\n\|/ /g;
?


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^6: Substitution in range operator
by benaw (Novice) on Dec 30, 2015 at 07:27 UTC

    I get the correct output but in my script it doesn't change the pipe or remove the new line. Funny because i copied the char into a hex editor and got "a" (new line not carriage return) I'll play around with it some more tomorrow but is there a way to use hex values in the regex? - just googled http://www.regular-expressions.info/nonprint.html so I'll have another look at a hex editor tomorrow and give it a go trying with hex symbols.

    foo | bar baz qux fred wilma barney

      I don't think I can use hex values in regex the hex is "a7c"

        sure you can, \x{a7c}
        $ perl -le " use Data::Dump qw/ dd /; dd qq{\x{a7c}} ; " "\x{A7C}"
Re^6: Subistution in range operator
by benaw (Novice) on Jan 07, 2016 at 05:54 UTC

    I get the correct output but in my script it doesn't change the pipe or remove the new line. Funny because i copied the char into a hex editor and got "a" (new line not carriage return) I'll play around with it some more tomorrow but is there a way to use hex values in the regex? - just googled http://www.regular-expressions.info/nonprint.html so I'll have another look at a hex editor tomorrow and give it a go trying with hex symbols.

    foo | bar baz qux fred wilma barney