我想从文件中解析一些信息。
文件中的信息:
Rita_bike_house_Sha9
Rita_bike_house
我想要像 dis 这样的输出
$a = Rita_bike_house and $b = Sha9,
$a = Rita_bike_house and $b = "original"
为了得到,我使用了以下代码:
$name = @_; # This @_ has all the information from the file that I have shown above.
#For matching pattern Rita_bike_house_Sha9
($a, $b) = $name =~ /\w\d+/;
if ($a ne "" and $b ne "" ) { return ($a,$b) }
# this statement doesnot work at all as its first condition
# before the end is not satisified.
有什么办法可以存储“Rita_bike_house”$a
和“Sha9”$b
吗?我认为我的正则表达式缺少某些东西。你能提出什么建议吗?