Welcome to the Monastery | |
PerlMonks |
Re: Nested subs - inherently evil?by ejf (Hermit) |
on Feb 11, 2002 at 20:38 UTC ( [id://144697]=note: print w/replies, xml ) | Need Help?? |
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 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 Section
Seekers of Perl Wisdom
|
|