September 2002
Intermediate to advanced
496 pages
10h
English
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, ...
Read now
Unlock full access