Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > perl script to write to a text file

Reply
Thread Tools

perl script to write to a text file

 
 
MOUNIL
Guest
Posts: n/a
 
      02-16-2005
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
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      02-16-2005
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
 
Reply With Quote
 
 
 
 
Mounilk
Guest
Posts: n/a
 
      02-16-2005
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

 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      02-17-2005
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
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      02-17-2005
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

 
Reply With Quote
 
Mounilk
Guest
Posts: n/a
 
      02-17-2005
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.

 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      02-17-2005
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
 
Reply With Quote
 
Mounilk
Guest
Posts: n/a
 
      02-17-2005
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.

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      02-17-2005
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 .

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI: Execute a perl script inside another perl script xdarcos@hotmail.com Perl Misc 20 01-18-2005 12:33 PM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments