Perl 匹配替换 变量 问题? 急急急!!!

a95586 2017-05-05 02:06:26
$test = "input";$parrten = "inpu";
if($test =~ /$parrten/){
print "$test\n";
}

结果显示:input

但是因为$parrten的值是inpu而不是input,如果想要在匹配时,只匹配inpu而不是input,即当$test的值为inpu时才能打印显示出来,变量匹配应该怎么写?
...全文
201 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
a95586 2017-05-08
  • 打赏
  • 举报
回复
嗯,结果差不多,初学Perl,对Perl的理解还是不够。。。谢谢!!!
sanGuo_uu 2017-05-05
  • 打赏
  • 举报
回复
试试看能不能用
#!/usr/bin/perl 

$test = "input";$parrten = "inpu";
if($test eq $parrten){
print "$test\n";
}
#!/usr/bin/perl 

$test = "input1";$parrten = "input1";
if($test =~ /^$parrten$/){
print "$test\n";
}

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧