However, although this works, it gives me a deep recursion
I'm not surprised. The question this begs to me is why the recursion. Something like this should suffice:
| hand waving here.
next if $_ =~ m/^hostname /;
Now, what is troubling me is when or how your re initializing the vars $tot2 and $tot. That would change my looking logic ever so slightly if I knew that.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg