samirpatry has asked for the wisdom of the Perl Monks concerning the following question:


i crate a client and server socket program using IO::Socket::INET module.Also i use the use File::Slurp 'write_file' module to write the incoming/outgoing message from the socket.
use File::Slurp 'write_file'; write_file( 'log1.txt',$sendmsg); write_file( 'log2.txt',$recvmsg);

But using this way i have to create different file for incoming/outgoing.Also it will store the last message only.But i want to append all the incoming and outing message in a single file.Plz suggest where i lack something

Replies are listed 'Best First'.
Re: How to write the incoming and outgoing message in a file ????
by shmem (Chancellor) on Aug 30, 2006 at 06:52 UTC
    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}