What is the alternative to perl structures?

Perl has no concept of a default structure. We need to import the Struct class. I was wondering why this is so? and What combination of basic data structures provided by the language should compensate for this?

+4
source share
4 answers

Hashes do pretty much the same thing in Perl as structures in C (in terms of what you use them for). You can also have socket hashes to create more complex data structures.

+11
source

If you have existing C header files with structs, use Convert :: Binary :: C to access data structures based on them.

+4
source

The :: Struct class never matches the role of C structures for me. In my opinion, the C structure is a well-known memory structure that organizes data, but for me it is best to use automatic analysis of fixed-length input data records into fields, just writing them to the structure.

You can do something similar with unpacking. It still requires a separate C syntax conversation, but if you write it in your entry, it is quite effective.

+2
source

You can try this module as an alternative to structs - Class :: Struct

0
source

All Articles