Perl language learning-from C/C ++ to Perl

Source: Internet
Author: User

Use strict;
Use warnings;
# Compare the value and string size
My $ str1 = "1-the first Str ";
My $ str2 = "1-the second Str ";
If ($ str1 = $ str2)
{
Print "numerically equal \ n ";
}
If ($ str1 EQ $ str2)
{
Print "stringwise equal \ n ";
}
Print "A. B". "Haha"

Examples of useful tests:

 

Use Strict;
Use Warnings;
My $ X = 1 ;
If ( $ X )
{
Print " X: Yes \ n " ;
}
My $ Y = 0 ;
If ( $ Y )
{
Print " Y: Yes \ n " ;
}
My $ Z = 0.0 ;
If ( $ Z )
{
Print " Z: Yes \ n " ;
}
My $ = " 0 " ;
If ( $ )
{
Print " A: Yes \ n " ;
}
My $ B = ' 00 ' ;
If ( $ B )
{
Print " B: \ Yes \ n " ;
}
My $ C = " 0.0 " ;
If ( $ C )
{
Print " C: Yes \ n " ;
}
My $ D = "" ;
If ( $ D )
{
Print " D: Yes \ n " ;
}
My $ E = "   " ;
If ( $ E )
{
Print " E: Yes \ n "
}
My $ G = " 0 " ;
If ( $ G = $ C )
{
Print " Numerically equal " ;
}
If ( $ G EQ $ C )
{
Print " String-wise equal " ;
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.