in reply to Regex to ignore comment

Can you show us data and what you expect to match/reject? Do you want to reject the first line in your __DATA__ section? Would it be easier to simply reject all lines that contain # ?

Replies are listed 'Best First'.
Re^2: Regex to ignore comment
by crusty_collins (Friar) on Oct 20, 2015 at 17:53 UTC
    I need to get the text before the comment IE # invalid

    __DATA__ [IP] regex = (?<First>..... pattern = 255.257.0.0 # invalid pattern = 192.168.1.1

      Why don't you just strip off everything starting with #?

      $line =~ s!#.*$!!; # strip off comments my( $key, $value ) = split /=/, $line;