Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I parse string using /gc and \G regexes. Current solution for skipping white characters and comments starting from # to the end of line is: $$a =~ /\G(?=(\s|#))(?:\s++|#.*+)++/gc;Look ahead ?= assertion is necessary, because zero-length matches cause problems. That solution unfortunatelly gives error: Complex regular subexpression recursion limit (32766) exceededI have changes to such one: while ($$a =~ /\G(?:\s++|#.*+)/gc) {};but this is not elegant. I have changed "+" to "*" after "\s" and this also solves the problem, but I don't know why... $$a =~ /\G(?=(\s|#))(?:\s*+|#.*+)++/gc;Questions: (1) what is the better solution to strip white chars and commments (2) why * instead of + solves the problem? In reply to Simple way to skip spaces and # comments by leszekdubiel
|
|