Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Perl regex txt file new line (not recognised?)

by kcott (Archbishop)
on Jan 22, 2020 at 06:20 UTC ( [id://11111717]=note: print w/replies, xml ) Need Help??


in reply to Perl regex txt file new line (not recognised?)

G'day thurinus,

Welcome to the Monastery.

As already indicated, it's likely you have line terminators not matching the '$'. You may have more success using '\R', the generic newline. See perlrebackslash: \R and note you'll need at least Perl v5.10 to use this.

Here's a quick-and-dirty example to compare '$' with '\R':

$ perl -E ' my @x = ( "A\n", "B.\n", "C\r", "D.\r", "E\r\n", "F.\r\n", "G\f", "H.\f" ); say q{*** With $ ***}; say "|$_|" for grep /\.$/, @x; say q{*** With \R ***}; say "|$_|" for grep /\.\R/, @x; ' *** With $ *** |B. | *** With \R *** |B. | |D. |F. | |H. |

In case you didn't know, the '\f' is a form-feed.

— Ken

Replies are listed 'Best First'.
Re^2: Perl regex txt file new line (not recognised?)
by Anonymous Monk on Jan 22, 2020 at 08:37 UTC

    Dear Monks,

    the line terminators were the issue and I could fix it with your help and suggestions.

    Thanks a lot for your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111717]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-20 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found