Relational and Logical Operators in PERL

Relational and Logical Operators in PERL

All programming languages have Relational and logical operators. Lets discuss on what Perl has as relational & logical operators.

  • The relational & logical operators are used with conditional statements and looping statements.
  • Perl’s relational and logical operators are same as C language and shell script.
  • All operators’ returns true if the condition satisfies else return False.

Relational operators

The C way

The shell script way

Description

>

gt

Greater than

<

lt

Less than

>=

ge

Greater than equal to

<=

le

Less than equal to

==

eq

Equals

!=

ne

Not equal

Logical operator

The C way

Description

&&

and operator

||

or operator

!

not operator

Other file operations

Operators

Description

-e filename File exist
-f filename Plane file
-d filename Directory
-s filename File size not zero
-r filename File readable
-w filename File writable
-x filename File executable
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s