faithless1
asked on
Appending Words
Hello,
I'm looking for a way to append a word at the end of each record which does not contain a specific word.
example:
shopping best store
shoppingrandomstore
expertshopping
expert shopping
ouput: Append "expert"
shopping best store expert
shoppingrandomstore expert
expertshopping
expert shopping
I'm also looking for a way to specify where to append a word ( beginning or end)
Thanks
I'm looking for a way to append a word at the end of each record which does not contain a specific word.
example:
shopping best store
shoppingrandomstore
expertshopping
expert shopping
ouput: Append "expert"
shopping best store expert
shoppingrandomstore expert
expertshopping
expert shopping
I'm also looking for a way to specify where to append a word ( beginning or end)
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
while( <DATA> ){
s/$/ $word/ unless /$word/;
print;
}
__DATA__
shopping best store
shoppingrandomstore
expertshopping
expert shopping