Re: can not filter out commentary lines with reg-exps



On Wednesday 29 March 2006 14:22, Harald wrote:
I need to parse an ASCII file which first rows are comments. Those rows
are marked by a '#' at their beginning.
I try to filter them out by

while( <$FH> =~ m{\#*} )

while( <$FH> =~ m{^\#.*} )

{}

But this does not work. The loop does never stop.
What goes wrong? I am really confused!

Your * refers to the #, saying you want to match all # occuring at least 0
times. My * refers to the . and so my regex says match a # at the beginning
of the line and the rest of that line (since * is greedy).

--
Bjørge Solli - Office:+47 55205847 cellph.:+47 91614343
Nansen Environmental and Remote Sensing Center - Bergen, Norway
http://www.nersc.no Reception: +47 55205800
Dept.: Mohn-Sverdrup Center for Global Ocean Studies
and Operational Oceanography
.



Relevant Pages