Search your unanswered perl queries
Google

Wednesday, December 3, 2008

Redirect to /dev/null

I came across a code snippet like `$ypmatch $host hosts 2>/dev/null` used in one of the perl files I was browsing. Can anyone let me know the significance of redirecting it to /dev/null.

I will post the same when I find it out.

Cleaning A Perl File With REGEXP

Following are the regular expressions which can be used to clean your file of unwanted material

1) Replace all the spaces with nothing.

s/\s//g;

2) Skip the lines with comments.

next if (m/^\#/);

3) skip blank lines

next if (m/^$/);

4) Replace a line in the file which has commented data on a code line.

s/\#.*$//;

5) Replace a line in the file which has data after semicolon

s/\;.*$//;