in reply to inserting string only once after matching a pattern

Many problems:

Replies are listed 'Best First'.
Re^2: inserting string only once after matching a pattern
by Anonymous Monk on Nov 06, 2006 at 06:52 UTC
    Thank You!

    I used the m{} syntax and fixed the regexp issues. I'm actually posting on a different computer from the code so the regexp issues were mistyping it.

    I'll study the different not equals soon. I didn't realize the the ne was the wrong syntax. I actually had (!~) initially but I read on a webpage that it's better to use "ne".

    At first I wasn't sure why I would need flag to determine if I'm in a multi-line /*...*/ comment. The syntax used in the files, always has a * as the first visible character in multi-line comments. Although you're right that it's not required. That's a nice catch. I haven't programmed in C in years.

    The only reason for accumulating the text is that the write commands are all together instead of spread out. The actual logic of the write operations take up a page of text and it's nice to treat the write operation as a single block. Since the files are small, avg. is 7k, and the largest are no more than 100k, memory is not a problem. Is this considered bad form in perl?

      I actually had (!~) initially but I read on a webpage that it's better to use "ne".

      When comparing against a constant strings, it's more efficient to avoid regexps.

      $var eq 'abc' $var ne 'abc' $var1 eq $var2 $var1 ne $var2
      are faster and simpler than
      $var =~ /^abc\z/ $var !~ /^abc\z/ $var1 =~ /^\Q$var2\z/ $var1 !~ /^\Q$var2\z/

      I'll study the different not equals soon.

      $var ne /regexp/
      means
      $var ne ($_ =~ /regexp/)

      • When matching against a regexp, use a match operator (=~ or !~).
      • When comparing strings, use a string comparison operator (eq, ne, lt, gt, le, ge or cmp).
      • When comparing numbers, use a numerical comparison operator (==, !=, <, >, <=, >= or <=>).