Search your unanswered perl queries
Google

Wednesday, December 3, 2008

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/\;.*$//;

No comments: