in reply to Regex to check for beginning character

You don't need a regex for an exact match like this.

foreach(@lines) { if ( index( $_, '#' ) == 0 ) { print "yahoo!"; } }
That's much faster than using a regex for this.

Replies are listed 'Best First'.
Re^2: Regex to check for beginning character
by Nkuvu (Priest) on Mar 05, 2004 at 16:39 UTC
    And of course you can simplify this to
    foreach(@lines) { print "yahoo!" if ( index( $_, '#' ) == 0 ); }
      That's not simplification. You're trying to win style points, but that's not how it's done (use parens only when neccessary) :)
      for(@lines){ print "yahoo!" if 0 == index $_, '#'; }