Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Totally new to Perl : Want help

Status
Not open for further replies.

archit

Programmer
Aug 22, 2002
19
US
Hi All ,
Going thru some site I chanced upon this excercise and found it be somewhat challenging. Will really appreciate if some one has inputs for this program.

PRoblem:

Create a class for the purpose of monitoring data coming from a named
pipe under Linux. Assume a daemon somewhere has the pipe open and is
continuously writing information to it. The class will be used as a
part of a larger program to monitor output from this named pipe and log
it to a file, so it is necessary to implement this class using fork()
or Perl threads to prevent the remainder of the program from blocking.

The constructor should take the following arguments:

named_pipe - String containing full path to the pipe to be monitored
(e.g. "/tmp/mypipe"), required
logfile - String containing full path to logfile to be written (e.g.
"/tmp/mypipe.output")

The constructor should not begin logging as in on() below, wait for the
user of the class to call those methods.

At least the following methods should exist:

on() - Start reading from the pipe and logging to the file. Append to
the file if it exists already. Return true if logging successfully
initiated.
off() - Stop reading from the pipe and logging to the file.
clean() - Unlink the log file.
dump() - Return an array of strings with the contents of the log file,
one line per string.
 
Perhaps your lecturer could help....

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top