如何使用写perl脚本,将在数组a里面的字符在数组b里面的数据选出来
usestrict;my@a={"a","b","c"};my@b={"a","d","e","f"};foreachmy$a(@a){foreachmy$b(@b){i...
use strict;
my @a={"a","b","c"};
my @b={"a","d","e","f"};
foreach my $a(@a)
{
foreach my $b(@b)
{
if($a=~ m/$b/)
{
print "$a\n";
}
}
}
这个程序该怎么改 展开
my @a={"a","b","c"};
my @b={"a","d","e","f"};
foreach my $a(@a)
{
foreach my $b(@b)
{
if($a=~ m/$b/)
{
print "$a\n";
}
}
}
这个程序该怎么改 展开
展开全部
少侠,你的数组定义有问题,应该是y @a=("a","b","c");和@b=("a","d","e","f");
其他的好像没什么问题
望采纳
具体代码如下:
use strict;
my @a=("a","b","c");
my @b=("a","d","e","f");
print "@a\n";
foreach my $a(@a)
{
foreach my $b(@b)
{
if($a eq $b)
{
print "$a\n";
}
}
}
其他的好像没什么问题
望采纳
具体代码如下:
use strict;
my @a=("a","b","c");
my @b=("a","d","e","f");
print "@a\n";
foreach my $a(@a)
{
foreach my $b(@b)
{
if($a eq $b)
{
print "$a\n";
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询