in reply to when $$s =~ m/\G.../gc is too verbose
Why not just store $$s in a local copy of $_?
#Either local $_ = $$s; #Or s//$$s/; #tricky.. ;-)
Actually, in this case, I'd be tempted to alter your approach altogether and use a regex table.
sub lexer { my ($parser) = shift; my $s = $parser->YYData->{INPUT}; # I don't get your line: 'm/\G\s+/gc; skip any spaces' my %dispatch = ( INT => qr/\G(\d+)/gc, ID => qr/\G([A-Z]\w*)/gc, #.. and so on .. ); while (my ($key, $regex) = each %dispatch) { return ($key, $1) if $$s =~ $regex; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: when $$s =~ m/\G.../gc is too verbose
by Corion (Patriarch) on Feb 07, 2006 at 17:58 UTC | |
by radiantmatrix (Parson) on Feb 07, 2006 at 19:32 UTC | |
|
Re^2: when $$s =~ m/\G.../gc is too verbose
by stefp (Vicar) on Feb 07, 2006 at 22:31 UTC |