Blog of Leonid Mamchenkov

You just stepped in a pile of posts.

Entries Tagged as 'unix'

Best shell alias ever

Posted in All on January 30th, 2006 · 2 Comments

I came across the best shell alias ever:

alias up="cd .."

This is one of those things that make me go “Why didn’t I thought of it earlier? And myself?”.

In order to add some value to this post, here are my two mostly used aliases:

alias pd="perldoc"
alias pdf="perldoc -f"

→ 2 CommentsTags: , , , , ,

Working with named pipes in Perl

Posted in All on September 14th, 2005 · 6 Comments

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.

[Read more →]

→ 6 CommentsTags: , , , , , , , , , ,

Analysis of two perl lines

Posted in All on July 6th, 2005 · 9 Comments

Today I saw these two lines in one backup script that was written in perl:

my $d = (localtime())[6];
$d = $d=~/[067]/ ? 0 : $d % 2 + 1;

Does this look cryptic to you? Probably not. But I wanted to write something and thought that these two lines won’t be that obvious for everyone out there. So I decided to explain exactly what goes on.

Before I start, I have to say that these are not just any two random lines of perl code. These are very useful lines that provide a short and elegant solution to a rather common problem. Read on if you interested.

[Read more →]

→ 9 CommentsTags: , , , , , , , ,

Advertisement

  • Advertise at mamchenkov.net
  • Flickr
  • Linux Weekly News