Clearly your regular expression just slurped the whole end of the file, rather than finding an end of line character.

In dos the default end of line character (which is actually two characters) is "\r\n", so it may be that the dos perl expects both of those characters to end the file. If you took your text file from linux and transferred it using a binary copy of some form, then your text file would still be in linux format, and would either need to be converted to dos (in standard linux you can do a dos2unix and unix2dos commands to convert between the two... at least I can on my redhat system...)

You can also change the end of line character that perl's searching for... okay so I'm calling it the wrong thing, it's really called the $INPUT_RECORD_SEPARATOR, or is called $/ in perl. Instead of it being set to \r\n, just set it to \n.

The other possibility is that there's a default in the regex. If that's the case, anchor your regex.

Instead of looking for m/particularly(.*)/ look for m/particularly(.*)$/

The $ says "go to the end of line" ($/ character sequence). It's a good practice to anchor your regexes if you want to garantee you're going to the end of a line, rather than slurping the whole file.

Hope that helps,

--Ray


In reply to Re: Find strings by raybies
in thread Find strings by toros

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.