OK, the aim of the code is to go through the first file (news.txt) and where it finds 'The Lecht' then match it to 'The Lecht' in the second file (resort_list_for_parser.txt).
Once matched it should then add in a appropriate anchor tag.

It seems to be grabing the data from the string 'Lech' instead.
Here's the code as requested:

The file's is opened and $line is set here:

open(NEWS,"news.txt") || die "Cannot open file"; my @news_lines = <NEWS>; close (NEWS); open(RESORT_LIST,"resort_list_for_parser.txt") || die "Cannot open fil +e"; my @resort_list_lines = <RESORT_LIST>; close (RESORT_LIST); foreach $line (@news_lines) { $line =~ s/\n\r//sgi; $line =~ s/\r//sgi; $line =~ s/\n//sgi;
Within the foreach above the follwing code exists:
foreach $resort_line (@resort_list_lines) { my ($resort_lookup,$resort,$country) = split (/:/,$resort_ +line,3); $resort =~ s/\r//sgi; $resort =~ s/\n//sgi; $resort_string_position = index($line,$resort_lookup); if ($resort_string_position != -1) { my $resort_lookup_length = length($resort_lookup); substr($line, $resort_string_position, $resort_lookup_l +ength) = "<html formatting>$resort_lookup</html formatting>"; } } }

Edit by tye: Replace BR with CODE tags


In reply to Re: Re: index() problem by Anonymous Monk
in thread index() problem by Anonymous Monk

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.