Can you explain a little more, please? In particular (and maybe only because it's been a long day), I don't understand:

I added the word CPLD to my string which is the third word in the txt file.

update for clarity: As "CPLD" is the second word in $teststring, I'm confused.

Based on a WAG, however, please note that for a match, your $rawdata will have to contain the complete sentence in $teststring.

So please post a reasonably small sample of your acrolist.txt.

Your script, minus one of the redundant declarations of my $newrawdata compiles and runs for me when run against a text file:

Hello CPLD this is just a test that I have created now. Bye, CPLD! This string does not have the magic accronym.

Compilation and execution produces the expected output, to wit,

pl_test$ perl -c 699458.pl 699458.pl syntax OK ~/pl_test$ perl 699458.pl Hello CPLD this is just a test that I have created now. Hello CPLD this is just a test that I have created now. Bye, CPLD! This string does now have the magic accronym. You have a MATCH! Hello CPLD this is just a test that I have created now.

In reply to Re: returning matched word from string by ww
in thread returning matched word from string by monaghan

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.