in reply to help with perl understanding

First of all, the Perl code-fragment you have provided is not related to “a C function.” That sort of thing is provided by a sub.

The Perl fragment that you have provided first declares five private variables, then enters a loop that reads a line of data from the standard-input. What might be throwing you off here is that there seem to be no actual references to the file, nor to the record that has been read from it, nor to the reading! Perl is big on “shorthand,” and it's very much a purpose-built language; its purpose is text-processing.

So the while-loop is reading from a file, and each of the if statements contain “regular expressions” (string patterns), which implicitly (because they do not use the operator =~) refer to the latest line that has been read from the input. (This line is contained in the very strangely named variable, $_. Don't ask me why Perl uses such odd names; maybe Larry Wall can't type good. I'm also not a fan of its insistence upon “funny characters” like $, @, % but once again it wasn't my idea...)

Some of the constructions in that Perl fragment are peculiar; in fact, the entire flow-of-control seems strange to me.

Anyhow, “Perl is what Perl is,” and even though the syntax of the language may throw you off for a few moments, your existing familiarity with embedded-C will soon come roaring back. Probably the most peculiar aspect of this language from that perspective is that, whereas “C” does almost-nothing for you, Perl does quite a lot. Garbage-collection and automatic memory management, for example; built-in hashes; a fairly-clever “reference” system for safe indirect addressing. Don't look at the Perl-5 source code unless you have a strong stomach... although you with your experience may well find it informative.