Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: $bad_names eq $bad_design

by pdcawley (Hermit)
on Dec 21, 2002 at 06:39 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found