>>>>> "Makhno" == Makhno writes: Makhno> I'm thinking of writing a GUI Perl-syntax-aware editor, and Makhno> wondering what's the best way to parse perl? Highlighting Makhno> reserved words is easy (using, eg, index()) but indentifying Makhno> things like comments is a bit more difficult. Makhno> A regex like /#.*\n/ will catch comments when they are used Makhno> simply, ie: Makhno> print "hello\n"; #print hello Makhno> but will get it wrong when the '#' is used as part of a regex Makhno> (or in a string) Makhno> s#hello#goodbye#; Makhno> print "will behave like a #comment"; Makhno> Does anybody have any ideas on how I go about parsing perl Makhno> syntax in such a way, before I go to a lot of potentially Makhno> unnecessary work? #### sin / ... time / ... localtime / ... caller / ... eof / ... #### use constant FOO => 35; FOO / ... use Fcntl qw(LOCK_SH); LOCK_SH / ... #### sub no_args (); sub one_arg ($); sub normal (@); no_args / ... one_arg / ... normal / ... #### use Random::Module qw(aaa bbb ccc); aaa / ... bbb / ... ccc / ... #### BEGIN { eval (time % 2 ? 'sub zany ();' : 'sub zany (@);'); } zany / ... #### sin / 25 ; # / ; die "this dies!"; time / 25 ; # / ; die "this doesn't die";