How to Use Fundamental Data Types in Perl

By eHow Computers Editor

Rate: (1 Ratings)

The PERL programming language uses a few fundamental data types. This range of data types includes variables and other designations for routines and file maps. The data types in PERL are identified by a "sigil," one ASCII character at the beginning of the identifying name that lets programmers know which data type they are working with or looking at. Use PERL data types according to their roles in the language.

Instructions

Difficulty: Challenging
Step1
Use scalars for strings, references, or other variables. The scalar is identified by a dollar sign, so $foo is an example of a scalar.
Step2
Utilize arrays to store scalars in ordered collections. The array, identified by a @, is a way to store variables in numeric order. @foo is an example of an array.
Step3
Try a hash or associative array to store scalars in a different way. A hash allows for an array where variables are not stored numerically but by specific "keys." %foo is an example of a hash identifier.
Step4
Use file handlers to manipulate files or data streams. The file handler is identified without a sigil and commonly in upper case letters: ex: FOO.
Step5
Apply subroutines for specific functions. A subroutine is not a variable but a block of "executable" code that variables can be passed to. A subroutine is identified by an ampersand: ex: &foo

Tips & Warnings

  • Be aware of variables changing from integers to strings. PERL treats the same variables differently according to context, so that a number might be seen as an integer when tied to an addition operator, but as a string in other situations. Know that the scalar can have either of these properties.
  • Look for variable "names" to identify hash operations. While the array will just show a row of variables, in a hash, they will be named. Finding variable names in code clues you in that a hash has been created.

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article: How to Use Fundamental Data Types in Perl

eHow Computers Editor

eHow Computers Editor

Category: Computers

Articles: See my other articles

Related Ads