in reply to Re: Insert and attach sequence of words in txt file if it exist in other file
in thread Insert and attach sequence of words in txt file if it exist in other file

this work thanks but here it copie sequence of words after . but me i want that it insert it before . i have some ligne in the a.txt that is like this <title> (here text)...</title > so in this case the sequence should be copied before </title>. should i change my @words = split / \./,$_; ?
  • Comment on Re^2: Insert and attach sequence of words in txt file if it exist in other file

Replies are listed 'Best First'.
Re^3: Insert and attach sequence of words in txt file if it exist in other file
by poj (Abbot) on May 13, 2017 at 20:40 UTC

    Is the . always at the end of the line ?

      yes

        In that case just remove it, add text and then add it back

        while (<FILE1>){ chomp; my @words = split /[ \.]/,$_; my @added; for (@words){ push @added,$file2{$_} if exists $file2{$_}; }; s/\.$//; print FILE3 $_,(join ' ',@added),".\n"; }
        poj