I thought $ works on Windows with carriage returns but it seems it doesn't...

It does. The OS-specific line terminator character(s) is/are translated somewhere in Perl's I/O layers to a common  \n newline character (which, IIRC, is 0x0a linefeed) — unless you're using binmode or some other form of raw read/write. The following code should execute identically (I believe) under any OS (I'm running this under Windoze 7):

c:\@Work\Perl\monks\marek1703>perl -wMstrict -le "use Data::Dump qw(pp); ;; for my $s (qq{foo\r\n}, qq{foo\r}, qq{foo\n}, qq{foo}) { if ($s =~ /foo$/) { print 'matched: ', pp $s; } else { print 'no match: ', pp $s; } } " no match: "foo\r\n" no match: "foo\r" matched: "foo\n" matched: "foo"
See definition of  $ in Regular Expressions - Metacharacters and its general discussion in perlre and perlretut. The match failures are due to the  \r stuck in the middle of things.

Also consider the following, which I also expect would work the same on any OS (it certainly works under Windows):

use warnings; use strict; while( <DATA> ) { if (/^"([^"]{2,})","(\d)","(.+)"$/) { chomp; my ($one, $two, $three) = ($1, $2, $3); print "matched: ``$_'' ('$one', '$two', '$three') \n"; } else { print "no match: ``$_'' \n"; } } __DATA__ "Sonntag, 26.05.2013 - 13:13:27","0","Lieber Herr % , & text text with + some %special characters" xyzzy "Mittwoch, 05.06.2013 - 18:12:09","0","Besten Dank, & hat prima geklap +pt. {Greetings!}"

In reply to Re^3: Escape special characters for a LaTeX file by AnomalousMonk
in thread Escape special characters for a LaTeX file by marek1703

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.