use strict; use warnings; #emulate reading from 1st file my %lookup = (); while (<DATA>) { chomp; my $key = (split /_/)[0]; $lookup{$key} = $_; } #emulate 2nd file my @input = ("I would like to learn this ! .", "OK ?"); foreach my $line (@input) { my @tokens = map {$lookup{$_} || 'unknown'} split /\s+/, $line; print "@tokens\n"; } 1; __DATA__ I_pron would_mod like_v to_to learn_v this_pron ._sent OK_ok ?_quest
In reply to Re: replacing while keeping the position of the element in the file
by Art_XIV
in thread replacing while keeping the position of the element in the file
by dra2pac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |