Also ... and as quickly as possible(!) ... step back and look at what this C program is designed to
, and whether an equivalent off-the-shelf bit of functionality already exists somewhere in the vast CPAN library. At the end of the day, you don't have to reinvent the wheel in Perl: you simply have to wind up with a functional equivalent of what that wheel does. And you'd like to do that with as little redundant effort as possible. C programmers had to do everything all-over-again from scratch. You do not.