I am iterating through a file line by line, picking out lines that start with asterix: *. My simple regexp works for all lines except the very first line of the file.
The DESIRED BEHAVIOR is: the regexp should correctly match lines that start with an asterix.
The ACTUAL BEHAVIOR is: if the asterix occurs on the very first line of the file, the regexp fails to match.
My DEBUGGING ATTEMPTS include:
Add empty line at start of file. RESULT: The formerly missed line, now at second line of file, is correctly matched by regexp.
Remove
\Afrom regexp, just match against asterix. The first line of file now correctly is matched by regexp.Try using
^instead of\A. First line of file still fails to match.
MINIMAL CODE TO REPRODUCE:
while (<$input_fh>) {
chomp;
$line = $_;
if ($line =~ /\A\*/) {
...
}
}
The input file consists of lines of text that may or may not start with an asterix.