in reply to Re: index() problem
in thread index() problem
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:
Within the foreach above the follwing code exists: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;
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: index() problem
by runrig (Abbot) on Feb 06, 2004 at 00:09 UTC | |
|
Re^3: index() problem
by Roy Johnson (Monsignor) on Feb 06, 2004 at 14:47 UTC |