in reply to Code refactoring challenge
Maybe...if( ( $statusLoadmsg = &FileExists( $logFile ) ) == $FALSE ) { &ResCode("WARNING"); &BrowseCode("File \"$logFile\" not found"); 
 &SummaryCode("WARNING"); return $WARNING; }
would do?do {warn "$logfile not found"; return $warning} unless -e $logfile;
...Hmm, is "readFileContents" any different than $contents = <$logfile>;(with $/=undef)? Then of course we have to ask why bother with the exsistance check in the first place. Oh, and what's up with all the $TRUE and $FALSE. Looks ugly and error prone to me. And by the description in the update, I'd guess you should be able to do what you want in less than 10 lines of code.# # read whole log file # if( &readFileContents( $logFile, $ContentsLoadMsg ) == $FALSE ) { &ResCode("E_LOADMSG_ERROR"); : &BrowseCode("Could not open \"$logFile\""); 
 &SummaryCode("E_MISLOAD_ERROR"); return $FALSE; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Code refactoring challenge
by castaway (Parson) on Apr 30, 2005 at 08:45 UTC | |
by Anonymous Monk on Apr 30, 2005 at 14:58 UTC |