perl script to write to a text file

Discussion in 'Perl Misc' started by MOUNIL, Feb 16, 2005.

  1. MOUNIL

    MOUNIL Guest

    hi ppl,
    I am a newbie just tinkering with perl. what i am trying to do
    at the moment is writing a script to listen in on a socket. i want to
    save the data passed on from the server script to the client script;
    in a text file. any help would be highly appreciated.

    thanks,
    Mounil
    MOUNIL, Feb 16, 2005
    #1
    1. Advertising

  2. MOUNIL wrote:

    > I am a newbie just tinkering with perl. what i am trying to do
    > at the moment is writing a script to listen in on a socket. i want to
    > save the data passed on from the server script to the client script;
    > in a text file. any help would be highly appreciated.


    What have you tried so far? What did it do, and how is that different from
    what you expected it to do?

    Have you read the posting guidelines that are posted here frequently?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Feb 16, 2005
    #2
    1. Advertising

  3. MOUNIL

    Mounilk Guest

    I've written 2 scripts in perl; one is the server side script and the
    other is the client side script. I run the scripts from two terminals.
    Both create,bind and listen in to the socket on the local host machine
    (127.0.0.1) . When the connection is established, the server script
    passes on some data onto the client script. For eg, just a statement
    like "You are now connected to the server". I havent been able to find
    out how i can save this data into a text file.

    - Mounil
    Mounilk, Feb 16, 2005
    #3
  4. Mounilk wrote:

    > passes on some data onto the client script. For eg, just a statement
    > like "You are now connected to the server". I havent been able to find
    > out how i can save this data into a text file.


    Open the file for output and print to it. See:

    perldoc -f open
    perldoc -f print

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Feb 17, 2005
    #4
  5. MOUNIL

    John Bokma Guest

    Sherm Pendley wrote:

    > Mounilk wrote:
    >
    >> passes on some data onto the client script. For eg, just a statement
    >> like "You are now connected to the server". I havent been able to find
    >> out how i can save this data into a text file.

    >
    > Open the file for output and print to it. See:
    >
    > perldoc -f open
    > perldoc -f print


    Have also a look at
    File::Slurp

    Or:

    yourscript.pl > out.txt

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
    John Bokma, Feb 17, 2005
    #5
  6. MOUNIL

    Mounilk Guest

    thanks Sherm.John, i really appreciate you helping me out. i couldn't
    really follow your suggestion. i am sorry if i sound naive,but i've
    just started using perl a couple of days. could you please elaborate on
    your suggestion.

    Thanks,
    Mounil.
    Mounilk, Feb 17, 2005
    #6
  7. Mounilk wrote:

    > thanks Sherm.John, i really appreciate you helping me out. i couldn't
    > really follow your suggestion. i am sorry if i sound naive,but i've
    > just started using perl a couple of days. could you please elaborate on
    > your suggestion.


    "perldoc" is a utility commonly used to read the documentation that comes
    with Perl. Other methods can be used too; for example ActiveState's Perl
    for Windows comes with documentation in HTML format as well.

    Regardless of whether you're actually using the "perldoc" tool or not, when
    you see the term "perldoc Foo" used here in this group, it's a pointer to
    the documentation that comes with Perl.

    When you're using the "perldoc" tool, "perldoc -q Foo" searches the FAQ
    questions for the word "Foo". "perldoc -f foo" will display the docs for
    the function foo(). And "perldoc Foo::Bar" will display docs for the module
    Foo::Bar.

    So, my suggestion to you was to read the documentation for the open() and
    print() functions. John's suggestion is good too - go to <http:/
    search.cpan.org>, find the File::Slurp module, and have a look at its
    documentation.

    And like I said before - please read (and follow) the posting guidelines
    that appear here twice a week.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Feb 17, 2005
    #7
  8. MOUNIL

    Mounilk Guest

    thanks a lot for that Sherm. You and John have been very helpfull. I
    will most certainly have a look at the posting guidelines tonight
    because i'll be using this group often and hopefully contributing to
    the group as well in the future. Once again, thank you.
    -Mounil.
    Mounilk, Feb 17, 2005
    #8
  9. MOUNIL

    John Bokma Guest

    Mounilk wrote:

    > thanks a lot for that Sherm. You and John have been very helpfull. I
    > will most certainly have a look at the posting guidelines tonight
    > because i'll be using this group often and hopefully contributing to
    > the group as well in the future. Once again, thank you.
    > -Mounil.


    What works for me: read a book front to back. Skip everything you don't
    understand. Just keep reading.

    Read it a second time, and mark the important parts. Also, try out the
    examples.

    I am doing this with "Dive into Python" and for me this works. There is no
    Dive into Perl afaik, but Learning Perl is probably a very good start too,
    and maybe better if you are new at programming Perl.

    If you are serious at Perl programming, buy the Cookbook too :-D.

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
    John Bokma, Feb 17, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,501
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,765
  3. pj
    Replies:
    3
    Views:
    273
  4. Petterson Mikael

    Execute another perl script from my perl script

    Petterson Mikael, Jan 5, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    125
    Paul Lalli
    Jan 5, 2005
  5. Replies:
    20
    Views:
    661
    Gunnar Hjalmarsson
    Jan 18, 2005
Loading...

Share This Page