Working with named pipes in Perl

The collegue of mine came across a problem that developed into an interesting solution that I decided to share with the world. Actually, I think the world is pretty much aware of the solution, but just in case that I will ever be looking for this solution again, I’ll have it handy here.

The task at hand was to do some processing of the logs on the fly. The syslog was configured to filter the appropriate logs into a named pipe and a Perl script was written to read from the said pipe and do all the processing.

The original piece of code looked something like this:

open (SYSLOG, "<$named_pipe") 
  or die "Couldn't open $named_pipe: $!\n";

while () {
  do_processing($_);
}

close(SYSLOG);

The problem came with syslog daemon restarts. Every time the syslog was stopped, the EOF was sent to the pipe and the script stopped reading it.

Continue reading Working with named pipes in Perl

Daily del.icio.us bookmarks

Shared bookmarks for del.icio.us user tvset on 2005-09-13

Andrei Sakharov

Andrei Sakharov (1921-1989) was a Soviet physicist who became, in the words of the Nobel Peace Committee, a spokesman for the conscience of mankind. He was fascinated by fundamental physics and cosmology, but he had to spent two decades designing nuclear weapons. The acknowledged father of the Soviet hydrogen bomb, he contributed perhaps more than anyone else to the military might of the USSR. But it was his top secret experience as a leading nuclear expert that was instrumental in making Sakharov one of the most courageous critics of the Soviet regime, a human rights activist and the first Russian to win the Nobel Peace Prize. He helped bring down one of history’s most powerful dictatorships.

The quote is from this site. If you are not familiar with this person, I suggest you browse through the link.

Irony in science or a bad example of Post Hoc

While reading through this excellent website I came across an article about Post Hoc logical fallacy. To freshen your memory, this article describes Post Hoc fallacy as follows:

A Post Hoc is a fallacy with the following form:

1. A occurs before B.
2. Therefore A is the cause of B.

There are also a few examples that help to understand this fallacy. Among these examples there is this one:

Bill purchases a new PowerMac and it works fine for months. He then buys and installs a new piece of software. The next time he starts up his Mac, it freezes. Bill concludes that the software must be the cause of the freeze.

I couldn’t help the smile. In the scope of logic as a science this example perfectly illustrates the point. But in the scope of computer science this quote would be a good example of the opposite. In other words, if you computer worked fine for months and than you installed a new piece of software on it, and it started to freeze – chances are that the software is the cause of problem.

Ironical, isn’t it?