Link to home
Start Free TrialLog in
Avatar of faithless1
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
Avatar of ozo
ozo
Flag of United States of America image

$word="expert";
while( <DATA> ){
   s/$/ $word/ unless /$word/;
   print;
}
__DATA__
shopping best store
shoppingrandomstore
expertshopping
expert shopping
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of faithless1
faithless1

ASKER

Thanks!