Help - I'm a C programmer. My code is rarely "cool". I was hoping you could turn this very functional code into something more....I don't know...clever, elegant, cool?
I pass a hash table to a function. This function checks the hash out every which way, and could make changes to it in a half dozen different places. The thing is, if a change is made, I have to do it all over again. And again. Until finally no more changes are made to the hash.
I use a global flag. If a change is made in the function, the flag is set to one and I know to repeat the iteration. Here's the code (ignore the %seen, it help me avoid unwanted recursion):
# Call the Find_First function
while($repeat_flag){
$repeat_flag = 0;
%SEEN = (); # reset hash
while(($k, $v) = each %GRAMMAR) {
&Find_First($k, $v);
}
}
Like I said, this works fine. But can I make it more, well, you know...
Thanks,
-tl
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.