Do you know where your variables are? | |
PerlMonks |
Re: Building a data Hierarchyby graff (Chancellor) |
on Mar 21, 2007 at 02:01 UTC ( [id://605779]=note: print w/replies, xml ) | Need Help?? |
Firstly, most of the code was donated by "Graff", however, I want to make it available to all as it works very well. I'm glad to see you have something working (after such a length development phase ;) But I'd just like to clarify that, at least in terms of raw byte count, I did not write "most of the code" posted above. I just provided the while (<DATA>) loop, the following "for" loop, and the "trace_down" sub. I think the post could be a more interesting contribution, and more people could find it useful, if that portion of your script were abstracted away from the database stuff. The basic premise is:
So as a general-purpose function, the while loop and for loop should be in a subroutine, whose parameters might be: input file handle, output file handle, maybe a string to use as the split regex. That and the "trace_down" sub could go into a "SortTree.pm" module, or something to that effect, to make it easier to re-use. As for the database stuff you've posted here, it's fine that it works for you, but I expect anyone else would just have to scrape it off, because it really only works for you. Also, it's not clear to me how or why the contents of the "resultsfile" (from the DB query) end up as pipe-delimited. Is that some sort of default setting on your database server, or in Win32::SqlServer? One last nit-pick -- you could replace all this: with this: Gotta love POSIX... (updated to add link to POSIX man page)
In Section
Code Catacombs
|
|