Perl | ne operator

ne‘ operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise not equal to the string to its right.

Syntax: String1 ne String2

Returns: 1 if left argument is not equal to the right argument

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

#!/usr/local/bin/perl
  
# Initializing Strings
$a = "Welcome";
$b = "Geeks";
  
# Comparing the strings using ne operator
$c = $a ne $b;
  
if($c == 1)
{
    print"String1 is not equal to String2";
}
else
{
    print"String1 is equal to String2";
}

chevron_right


Output:

String1 is not equal to String2

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#!/usr/local/bin/perl
  
# Initializing Strings
$a = "Geeks";
$b = "Geeks";
  
# Comparing the strings using ne operator
$c = $a ne $b;
  
if($c == 1)
{
    print"String1 is not equal to String2";
}
else
{
    print"String1 is equal to String2";
}

chevron_right


Output:

String1 is equal to String2


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.