Perl to shell script

Following is the code in perl. Can we write the same thing in shell scripts ?? If yes how ? I have used associative arrays but unable to achieve what this is doing

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];      #an associative array to store first 2 line info
    $count++;

Something like this

awk -F, '{gsub(/\"/,x);for(i=1;i<=NF;i++){a;};getline;gsub(/\"/,x);for(i=1;i<=NF;i++){a=$i}}' file

:open_mouth:

please explain the code you have written

Also,in the perl snippet there were two associative arrays line1 and line2 wherein the values were being stored. How are you doing it in shell ??
and what is the keyword 'file' for ?
can $1 be used instead ??

~thanks

First of all, there is an error in my awk and this code is likely to suit your need

awk -F, '{gsub(/\"/,x);for(i=1;i<=NF;i++){a=$i;};getline;gsub(/\"/,x);for(i=1;i<=NF;i++){array[a]=$i}}' file

I see only one associative array %array on your code @line1 and @line2 are regular arrays. My understanding of your need is that you have a file

"abc","def","hij"
"123","456","789"

You want to assign

$array{"abc"} = 123, $array{"def"} = 456 

If this is not your need, then you can well ignore the awk script and clearly post your need.

The awk script grabs the first line, removes all double quotes, puts the column values on an array 'a'. Then go to next line, iterate on the columns and creates an array 'array' (which is the associative array that you finally need) and use the previously assigned array 'a' to make a column to column assignment.

'file' is the file path of MYFILE in your script.

What do you refer by $1 ? Do you need a perl one liner for this need?

thanks it done