[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Re: HUMOR: you have to see this code!



On Sun, Nov 07, 1999 at 12:59:42PM -0500, Michael G Schwern wrote:
> 
> 	It -truly- works.  Meaning it works under the current conditions
> and test cases and will continue to work under increasingly demanding
> conditions.  [the only two obvious examples I see in this code is
> get_days_since_new_year() which will break next Feburary and the
> busted $LOCK_* constants which only happen to work out of dumb luck
> ($LOCK_SH and $LOCK_EX are correct by co-incidence, the rest are wrong
> but he never uses them).]
> 

How about this lovely subroutine:

sub get_random_value_in_index_table ($) {
    if($_[0] eq $lady_site_data_file_path){
        local $index_path = @_;
        local %LADY_TABLE = &get_index_table ($_[0]);
        local @LADY_ARRAY = values (%LADY_TABLE);
        local ($lines) = scalar (@LADY_ARRAY) - 1;
        local ($random_selection) = &random_option ($lines);
        local ($random_line) = $LADY_ARRAY[$random_selection];
        }
        else{
        local $index_path = @_;
        local %TABLE = &get_index_table ($_[0]);
        local @TABLE_ARRAY = values (%TABLE);
        local ($lines) = scalar (@TABLE_ARRAY) - 1;
        local ($random_selection) = &random_option ($lines);
        local ($random_line) = $TABLE_ARRAY[$random_selection];
        }
        return ($random_line);
}

Too much code!  I would rewrite this, with the same functionality, as:

sub get_random_value_in_index_table ($) {
        return ($random_line);
}


Also note that $index_path will always be set to 1.  Good thing he doesn't
use it.



Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe