Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

mako132 (2925)

Journal of mako132 (2925)

Tuesday October 29, 2002
03:12 PM

Factoring

[ #8666 ]
Doing more work on the repeated code tools.  My grand idea was a tool
which took repeated code out of a script and put it into a library
file.

I doubt I could get it completely automated.  My goal is make a tool
that helps build this library file.  I would probably have to leave
repeated code (for context sake) in the original file (commented out).

As a start, I wrote a separate script which took the output of my
repeated-code detector and marked up the file with lines such as,

>>> 435      ## Gets the starting time
>>> 436      $decode_start_time = timelocal( 0, $minutes{$decode_start_minute} , $hours{$decode_start_hour} , $sys_day , $sys_months{$sys_month} , $sys_year);
>>> 438      my $current_time =  scalar(localtime( $time ));
>>> 439      my $decode_sess_start_time =  scalar(localtime( $decode_start_time ));
>>> 440      my $decode_sess_end_time =  $decode_start_time + $seconds{$seconds_decode} + (  $minutes{$minutes_decode} * 60 ) + ( $hours{$hours_decode} * 60 * 60);
>>> 441      $decode_sess_end_time = scalar(localtime( $decode_sess_end_time ));

The numbers above are the line numbers of the first occurrence of the
same code.  For example ">>> 435" means this exact line (not counting
whitespace) appeared earlier on line 435.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.