Monday, May 9, 2011

comparators in perl and shell

SHELL:

KSH

you can use == or = to compare string

bash: if you use "==" will lead to syntax errors so be cautious,we have to use only "=" in this case.

Another speciality about = operator is it can be used for both string and numbers.

and can use -eq  for only comparing numbers

And -eq if used for compring strings,it will return syntax error.

PERL

it is just the opposite what you  use in shell

eq can be used to compare only string

= can be used for only numbers

Though = may seem to work for strings it will always return true.So be Cautious.

No comments:

Post a Comment