While I'm not sure what exactly you are asking for, I'm going to try to answer anyway. ;-)
First off, nested subs aren't neccesarily evil. In a way, a class/module is nothing more than specially nested subs. If it looks right, it usually is.
As to hardcoding BINFILE into your sub : why ? You could just pass the filehandle as an argument to ReadBytes as well. You could even use objects (see IO::File) if you're uncomfortable passing fileglobs around ...
You could also eliminate ReadBytes completely ... a
read(BINFILE, $_, 4) && map (unpack("C", $_), split(//))
will yield the same as ReadBytes -- depending on how often you use it, this might be preferable (or maybe you can use it to shorten the ReadBytes sub into a oneliner ;) These functions are all discussed in perlman:perlfunc, amongst others ...
As I don't know what ParseData will ultimately do with these bytes, it's difficult to optimize these routines further -- maybe you don't even need the bytes separated into lists of integerized chars ... ;)
update : I forgot completely about unpack -- as seen in traveler's post, a read(BINFILE, $_, 4) && unpack ("C4", $_) would do just as nicely. I'm not sure, but even unpack ("C".read(BINFILE, $_, 4), $_) might work if you're sure there's enough data left to be read.
In reply to Re: Nested subs - inherently evil?
by ejf
in thread Nested subs - inherently evil?
by myocom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |