Rudimentary PERL – Part 2

Last week, we wrote our first PERL script and we got introduced to scalar variables. A scalar variable will store exactly one item, like it can store one number or a string or a line of standard input.

An important thing is how you name the scalar variable or the syntax.

  • It cannot start with a number. $2ac, $5 is illegal
  • It cannot have any special character.$abc@, $dff! Is illegal
  • It should either start with an alphabet or a _. $a_, $_a, $a are legal
  • You can have a very long name. $This_is_a _long_name is legal.
  • $hi, $HI, $hI are all different variables; means its case sensitive.

Basic Arithmetic operators like +, -,*,/ follow the age old BODMAS rule when present in a statement.

There is this function called chop. As the name suggests, it chops the right most character of a string or the trailing newline.


Conditional Statements Syntax:

The PERL interpreter executes through if-elsif-else only once when it encounters it.


But it is different for while and until statements.



while loops gets executed until the conditional expression remains TRUE.

until loop gets executed while the conditional expression remains FALSE.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s