use strict; use warnings; use Data::Dumper; use Math::Expression::Evaluator::Lexer qw(lex); my $d = do { local $/; }; my @tokens = ( ['Commment', qr{/\*.*?\*/}s, sub { return }], ['Identifier', qr{[a-zA-Z_]\w+}], ['Number', qr{\d+}], ['Operator', qr{[=(),+-/*{}]}], ['Quoted String', qr{"[^"]*"}], ['Newline', qr{\n}], ['Whitespace', qr{\s+}, sub { return }], ); print Dumper lex($d, \@tokens); __DATA__ /* A 2-dimensional sequence as the value is being called in ODL */ KEYWORD = ((1,2) (3,4) (5,8) /* some comment */ 9,11)) /* A set as the value is being called in ODL */ KEYWORD = { RED, BLUE, /* some comment */ GREEN, HAZEL } /* A text string spanning multiple lines */ KEYWORD = "some text /* not a comment but part of the value! */ more text even more text" /* this is again a comment*/