in reply to Re: Support for hash comments on a line
in thread Support for hash comments on a line

Just a thought, using the prematch and postmatch at all will slow down all regular expressions as the engine will have to save them for every regex in your program.

-Lee

"To be civilized is to deny one's nature."
  • Comment on Re: Re: Support for hash comments on a line

Replies are listed 'Best First'.
Re3: Support for hash comments on a line
by blakem (Monsignor) on Nov 02, 2001 at 10:10 UTC
    After reading chapter 5 of japhy's book, you'll be able to rewrite prematch as:
    substr($string, 0, $-[0])
    For example:
    #!/usr/bin/perl -wT use strict; while (<DATA>) { chomp; $_ = substr($_, 0, $-[0]) if /#/; print "$_\n" if $_; } __DATA__ ### Hello 99:88:77 100:11# This is a comment abc:def ### Comments also 999

    -Blake