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



Harald wrote:
Hi,

Hello,

I need to parse an ASCII file which first rows are comments. Those rows
are marked by a '#' at their beginning.

You need to use '^' instead of '\' to indicate the beginning of a line.

I try to filter them out by

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

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

Your pattern says to match zero or more of the '#' character and every line in
your file has at least zero '#' characters. You want something like:

1 while <$FH> =~ /^#/;



John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Re: Big Picture vs Expanding Viewpoint
    ... >> beginning of Harald might overwhelm me enough to turn me off. ... >> Maps, indexes, glossaries, whatever works best for your story. ... >Baen site starting at the beginning, readers there don't have it. ... a character has cropped up and I can't recall if it's a character that ...
    (rec.arts.sf.composition)
  • Re: Interpreting "(.*?)" and "(?:d+ [.]?)" in REs
    ... after one of those quantifiers makes it non-greedy. ... - match zero or one 'a' characters ... The second question mark follows a character set, ...
    (comp.lang.ruby)
  • Re: A dilemma
    ... character in the sequel, "Threshold". ... In _Harald_, Anne was supposed to be a minor character. ... Author of _Harald_, a fantasy without magic. ... Published by Baen, in bookstores now ...
    (rec.arts.sf.composition)
  • Re: Future Building Questions 001
    ... _character_ who believes a theory the writer doesn't believe in. ... Part of what is going on in _Harald_ is a clash of viewpoints between ... the protagonist and an important secondary character. ... Author of _Harald_, a fantasy without magic. ...
    (rec.arts.sf.composition)
  • Re: Future Building Questions 001
    ... character who believes a theory the writer doesn't believe in. ... King put it, explaining his attempt to convert allies into subjects: ... The first step, which he has royally messed up, is converting allies ... Author of _Harald_, a fantasy without magic. ...
    (rec.arts.sf.composition)