Data Types
Data Types
- Scalars
- Arrays & Lists
- Hashes
- References
- Filehandles
It's all
about context
- Perl is smart enough to know how you're using something
- Numerics can be strings; strings can be numerics
- Arrays can be scalars
- Hashes can be arrays
- Arrays can be hashes
Scalars
- Single value
- Arbitrary large
- Can contain binary data, even nulls.
- Can be numeric or string, depending on context
Arrays/Lists
- Arbitrary-sized array of scalars
- Can contain any scalar
- Used when you want to preserve order of something
Hashes
- Collection of scalars
- Keyed by a unique case-sensitive string
- Useful for lookups or checking for existence
- Same as associative arrays in awk, or the CMap class in MFC.
References
- Is a scalar, and can be used anywhere a scalar can
- Perl version of pointers
No comments:
Post a Comment