epanda wrote:
> this is not working
> 
> here is an example of my file and I just want to replace with one
> regexp
> 
> in file1 ddd ddd dddd by the value stored in my hash table
> in file2 all d
> in file3 not the first d; but all the others      which is preceed by
> WORD;
> 
> in all files
> not replacing block like that d;d;dd
> not replacing the 2 in WORD/WORD2;
> 
> file1
> WORD/WORD2;                         d;d;dd;    d;d;dd;  d;d;d;
> d;d;d;   ddd  ddd  ddd  ddd  dddd
> WORD/WORDWORD1/WORD1;  d;d;dd;    d;d;dd;  d;d;d;  d;d;d;   ddd  ddd
> ddd  ddd  ddddd
> 
> file2
> WORD;  d;  dd;  dd;  dd;  d;  d;  d;  dd;  dd;  d;  ddd;  ddd;  ddd;
> ddd;  ddd;  dddd;
> 
> 
> file3
> WORD/WORD1;  d;   d;  ddd;  dddd;
> 
> 
> Thanks Rob if you can help

I think you should post some real data so that we can see the difference between
the fields you want translating. It's not clear, for instance, whether WORD is
always the same word or if it can be used to determine the behaviour of the
replacement.

This seems to be close to what you need:

    s/ (?<!;) \b (\d+) (?!;\d) /exists $hash{$1} ? $hash{$1} : $1/exg;

but I can't see how to distinguish the first d; in file3 to be left unmodified.

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to