以下是perl中的代码。 我们可以在shell脚本中编写相同的东西吗? 如果是的话如何? 我已经使用关联数组,但无法达到这个是什么做从Perl到shell的脚本转换
open MYFILE, "<", "$ARGV[0]" or die "Can't open $ARGV[0] file \n";
############ to retieve the info and put them in associative arrray ##############
$line = <MYFILE>;
@line1 = split(/,/ , $line);
$length = @line1;
$count = 0;
while($count < $length)
{
$line1[$count] =~ s/^\"//;
$line1[$count] =~ s/\"$//;
$count++;
}
$line = <MYFILE>;
@line2 = split(/,/ , $line);
$length = @line2;
$count = 0;
while($count < $length)
{
$line2[$count] =~ s/^\"//;
$line2[$count] =~ s/\"$//;
$count++;
}
$count = 0;
while($count < $length)
{
$array{$line1[$count]}=$line2[$count];
$count++;
}
我确定上述可以在bash中重写。你有尝试过什么吗?如果是的话出了什么问题? – marderh
我想知道你为什么要从Perl转换到shell。 –