Error in perl matching

We got this error by running:

 

my $str = "reb,cheng";

$str = ~ s/,//;

print $str, "\n";

 

seems everything is okay, but why?

Here is the error message:

C:\Rebecca\script\perl>perl status_v0.2_clear.pl

Use of uninitialized value $_ in substitution (s///) at status_v0.2_clear.pl line 88, <DATA> line 751.

18446744073709551615

 

Notice there is a space between “=” and “~”, the correct way should be NO SPACE between them:

my $str = "reb,cheng";

$str = ~ s/,//;

print $str, "\n";;

 

then we got:

C:\Rebecca\script\perl>perl status_v0.2_clear.pl

rebcheng

 

It is executed successfully after removing the space!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章