in reply to clean code
I pretty much like what you have already! It's easy to understand and robust. The only thing I think you really ought to change are the backslashes in the split regexes, which shouldn't be there.
All the other changes I'd make are superficial. Structurally, the temporary variable @vals can be eliminated by putting it within the loop initializer. Stylistically, I think you ought to leave off the comment marking the end of the loop, as you're already practicing proper indentation, and that's sufficient. Here's some code I might have written:
# extract name-value pairs from serialized database row for my $pair ( split( /;/, $serialized_row ) ) { my ( $name, $value ) = split( /=/, $pair ); $record{$name} = $value; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: clean code
by sfink (Deacon) on Apr 23, 2006 at 05:42 UTC | |
by creamygoodness (Curate) on Apr 23, 2006 at 18:21 UTC |