Today i will give you an idea here’s what you would need if you want to
skip blank lines or lines that have a ‘#’ at the start (or after
one or more white-space characters, i.e. spaces, tabs etc.):
while ( < $f> ) {
next if /^\s*($|#)/;
do_something_with_the_line( $_ );
}
The stuff in between the slashes is the regular expression,
applied to try to match the default argument ‘$_’, which in
this case is the line you just read in from the file.
The ‘^’ at the start says that the comparison is to start at
the very beginning of the line. The ‘\s*’ matches an unspe-
cified number of white-space charecters (between 0 and as
many as there are). The ‘$|#’ means: either the end of the
line (‘$’) or a ‘#’ character, with the ‘|’ being the or
operator. Thus the whole line can be read as: next if the
line just read starts with zero or more white-space charac-
ters, followed by the end of the line or a ‘#’ character.
The paranthesis around the ‘$|#’ are necessary because
/^\s*$|#/
would mean: match if the line either just comtains zero or more
white space characters (i.e. it’s a blank line) or if there’s a
‘#’ to be found anywhere within the line.
Incoming search terms:
- perl skip blank lines (49)
- perl skip empty line (15)
- perl ignore blank lines (13)
- Perl skip empty lines (12)
- perl ignore blank line (6)
- perl skip blank line (6)
- perl ignore white lines (5)
- skip empty line perl (5)
- skeap an empty line in a file perl (5)
- perl skip comment lines (4)
- skip blank line perl (4)
- perl ignore comment line (4)
- perl ignore empty line (4)
- empty line perl (4)
- perl detect blank line (4)
- empty line in perl (4)
- skip empty lines perl (3)
- How to match empty lines comments white spaces in perl (3)
- skip empty lines in perl (3)
- perl read file skip empty lines (3)
- perl empty line (3)
- perl ignore comments (3)
- how to skip blank lines in perl (3)
- skip blank lines perl (3)
- perl script skipping blank lines (3)
- perl ignore comment lines (3)
- skip white lines perl (3)
- perl skip commented lines (3)
- perl check for empty line (3)
- ignore blank and comment lines java (2)
- perl skip whitespace lines (2)
- perl skip if blank (2)
- perl skip empty line whitespace (2)
- matching empty lines in perl (2)
- perl file read line ignore empty line (2)
- perl detecting blank lines (2)
- perl file read line exclude blank comments (2)
- perl skip beginning blank lines opening file (2)
- perl tutroial skip a line (2)
- perl windows read file skip comments (2)
You will also be interested in ,
- Random password generator using perl script
- Get ipaddress using perl script
- Split /etc/passwd file using perl script
- How to find Operating System name using perl script
- Simple webpage redirection using perl script
- Simple User Input And Sleep Functionality Using Perl Script
- Reading input from keyboard and finding the sum using perl
- How to run CGI or Perl Scripts in IBM Http Server [IHS] or Apache Servers
- Commenting Multi Lines In Perl Script
- A reference to valid parameters for cookie call in perl

