Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: $bad_names eq $bad_design

by pdcawley (Hermit)
on Dec 21, 2002 at 06:39 UTC ( #221585=note: print w/replies, xml ) Need Help??

in reply to $bad_names eq $bad_design

Me? I worry about those global variables like $file, $html, %CONFIG and %REPLACEMENTS and find myself wondering if it wouldn't be better to make them attributes of the parser object:

sub ParserClass::do_global_replace { my $self = shift; while (my $token = $self->get_token) { $self->maybe_do_replacement($token); } return $self } sub ParserClass::maybe_do_replacement { my $self = shift; my $token = shift; if ($self->stack_matched) { $self->append_replacement_html; } else { $self->append_html($token); } return $self } sub ParserClass::append_replacement_html { my $self = shift; $self->append_html($self->replacement_html); $self->increment_replacement_count; }
(Admittedly, some of the utility functions are left as an exercise to the interested reader, I'm assuming that you have a parser per file and I worry that 'stack_matched' is still a bad name for the function, but I can't think of a better one at present. With these changes in place, your while loop becomes:
$html = $parser->do_global_replace->html;
I still worry mind. Now I'm worried that the parser is doing too much...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://221585]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2016-10-28 18:44 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (386 votes). Check out past polls.