F
Francois Massion
I couldn't find so far a solution to a quite common problem:
There is a document in which some words occur many times. I want to
replace ONLY THE FIRST instance of the word and leave the other
instances unchanged.
Here my code:
(...)
foreach $sentence (@document) {
chomp $sentence;
$sentence =~ s/Subject/Topic/;
push (@result,$sentence);
}
(...)
I have tried to use the modifier "o" for "once" but it didn't work as
well:
$sentence =~ s/Subject/Topic/o;
Any suggestion?
Thanks
Francois
There is a document in which some words occur many times. I want to
replace ONLY THE FIRST instance of the word and leave the other
instances unchanged.
Here my code:
(...)
foreach $sentence (@document) {
chomp $sentence;
$sentence =~ s/Subject/Topic/;
push (@result,$sentence);
}
(...)
I have tried to use the modifier "o" for "once" but it didn't work as
well:
$sentence =~ s/Subject/Topic/o;
Any suggestion?
Thanks
Francois