in reply to How to write the incoming and outgoing message in a file ????

Please read the documentation of File::Slurp:
write_file( 'filename', {append => 1 }, @data ) ;
is the right way to append to a file. Your call to write_file overwrites the file.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}