in reply to Re^2: deleting special lines from files
in thread deleting special lines from files
and you just want to skip lines that start with a semi-colon, then just add one line at the top of the loop like this:while (<>) { # or maybe using a file handle, like <IN> # do stuff... }
If you also want to delete lines with double semi-colons (because these represent empty fields), adjust that first line within the loop as follows:while (<>) { next if ( /^\s*;/ ); # skip if first non-space char is ";" # now do stuff... }
The "next" statement simply causes the script to skip everything that follows in the loop, and go right to the next iteration. The regular expressions in the "if" statement are saying:while (<>) { next if ( /^\s*;/ or /;;/ ); # now do stuff... }
^ -- line begins with... \s* -- zero or more white-space characters ; -- followed by a semi-colon or ;; -- there are two semi-colons together anywhere in the line
|
|---|