I have a text file with three occurrences of the string 'object'.
There is an object on the table
The object is under the chair
There might be an object in my pocket
I want to write a Perl script to replace every occurrence of 'object' with another string contained in an array of three elements. The first element of the array is matched to the first occurrence of 'object', the second element to the second occurrence, and so on.
For example, if
my @pattern = ( "apple", "mango", "orange" );
Then the output must be:
There is an apple on the table
The mango is under the chair
There might be an orange in my pocket