Collections of Records
A record is a set of related data fields. For example, the name, address, and phone number are a set of fields that, when taken together, form a payroll record. Keep in mind that Perl does not have any formal treatment of records, and thus the programmer must be creative. Most programmers keep track of records by using anonymous hashes. If you are a C programmer, you can appreciate the similarity between record creation in C and Perl. The C approach might be
struct record { char name[100]; int age; }; typedef struct record RECORD; RECORD create(char *name, int age) { RECORD r; strcpy(r.name, name); r.age = age; return r; } main() { struct record a,b; a = create("Mike",54); printf("%s %d\n", a.name, a.age); }
In Perl, ...
Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.