in reply to Re^2: Store and print multiple strings
in thread Store and print multiple strings
Sorry about that, I didn't read your code carefully enough, and managed to overlook the initial '.' in your regex, and managed to flub my initial response.
If you're always getting six values and you want to format them as you describe, I don't really see any reason to prefer splitting them up before putting them in the hash versus splitting them up afterwards when you're printing your report.
Generally, I try to let the problem I'm solving guide my choices on building the data structure. If you're doing further processing between the "acquire the data" step and the "report the data" step, then that further processing might be simpler if the data were stored one way vs. storing it the other way. If you don't have an intermediate step yet, but suspect you may in the future, then you might want to put the data in a format suitable for the expected processing if it's no more difficult one way or the other. If there's any extra effort required to put the data in that form and you're not sure you'll use the script again, then you might just put a nice comment in the form of:
# TODO: if we need to jibber the frobnitz, we might want to reform +at the data like # $lag_load{$lag_traffic} = [ [ $inVal1, $outVal1 ], ... ]; # or # $lag_load{$lag_traffic} = [ { in=>$inVal1, out=>$outVal1 }, ... +]; # be sure to update the zig_zag_report subroutine accordingly!
to prompt the future you, if/when the need arises. That way, you don't have to spend the effort unless necessary. Since it's just a comment to give you a little context when you revisit the code, it need not be syntactically perfect--you're just wanting to pass on some ideas to your future self while the code is fresh in your mind.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|