YUANya

导航

 

控制结构

#!/usr/bin/envperl

use strict;
use warnings;

my $word = chr (0x05D0);print "$word\n";

my $code_point = ord( 'א' );print "$code_point\n";

print "\x{05D0}\n";

##Wide character in print at test.pl line 6.
##א
##215
##Wide character in print at test.pl line 10.
##א

my $right_first = 4 ** 2 ** 3; print "$right_first\n";

my $left_first = 32 / 8 * 4; print "$left_first\n";

##65536
##16

if ( '35' eq '35.0')
{
  print "right\n";
}
else
{
  print "wrong\n";
}

##wrong

if ( "35" == "35.0")
{
  print "right\n";
}
else
{
  print "wrong\n";
}

##right

if ( "35" eq "35.0")
{
  print "right\n";
}
else
{
  print "wrong\n";
}

##wrong

if ( 35 == 35.0)
{
  print "right\n";
}
else
{
  print "wrong\n";
}

##right

if ( ' ' lt '  ')
{
  print "right\n";
}
else
{
  print "wrong\n";
}

##right

my $number_judge = ( 35 == 35.9 );print "$number_judge\n";

my $number_judge = ( 35 == 35.0 );print "$number_judge\n";

my $number_judge = ( '35' eq '35' );print "$number_judge\n";

my $char_judge = ( "35" eq "35.0");print "$char_judge\n";

##
##1
##1
##

my $still_true = !! 'apple';print "$still_true\n";

my $still_fake = !! 0;print "$still_fake\n";

##1
##

my $text = <STDIN>;chomp($text);

my $new_text;chomp( $new_text = <STDIN>);

print "$text = $new_text\n";

my $text1 = <STDIN>;my $words_number1 = chomp($text1);print "$words_number1\n";

my $text2 = <STDIN>;my $words_number2 = $text2;print "$words_number2\n";
##input
##input
##input = input 
##input
##1
##input
##input

my $n = 0;
my $sum; $sum = $n +1; print "$sum\n";

##1

my $empty;my $new_empty = $empty;

my $empty1;my $new_empty1 = $empty1;print "$new_empty1";

##1
##Use of uninitialized value $new_empty1 in string at test.pl line 126, <STDIN> line 4.

my $char_undef ;my $respond = defined($char_undef); print "$respond\n";
my $char_empty = "";my $respond1 = defined($char_empty); print "$respond1\n";

##
##1

在这里有个问题:是否无论判断数字的布尔和判断字符串的布尔判断具有相同的结果,即真为1假为空(即undef)?

my $number_judge = ( 35 == 35.9 );print "$number_judge\n";

my $number_judge = ( 35 == 35.0 );print "$number_judge\n";

my $number_judge = ( '35' eq '35' );print "$number_judge\n";

my $char_judge = ( "35" eq "35.0");print "$char_judge\n";

##
##1
##1
##
posted on 2019-06-09 21:57  YUANya  阅读(95)  评论(0编辑  收藏  举报