Convert perl to shell

Hi
I am a novice in scripting .Please help me converting perl script into shell

my ($ref) = shift;
 my $id;
 my $cnt=0;
 my $first =0;
my $filename ;
my $filename1  ;   
     FOREACH:foreach my $r (qw(RET LSH PDM )) {
      $ref->{$cnt}->{num_errors} =0;
  $ref->{$cnt}->{num_warnings} =0;
 
        if($first==0){
   $filename = "$PASS_DIR/$r.rpt"; 
          $filename1 = "$PASS_DIR/${r}_su.rpt";
    $ref->{$cnt}->{is_raw} =1; 
 }else{
   $filename = "$PASS_DIR/$r.rpt";
   $filename1 = "$PASS_DIR/${r}_su.rpt"; 
    $ref->{$cnt}->{is_raw} =0;
 
 }
    $ref->{$cnt}->{type}= $r;
  if(!-e $filename1){
   $ref->{$cnt}->{sumf}= '';
  }else{
   $ref->{$cnt}->{sumf}= $filename1;  
   }
   
    if(-e $filename){  
   my $start = 0;
               while ( my $line = <IN> ) {
  if ( $line =~ m/\s*(${r}.*)\:/ ) {
                    $id    = $1;
                    $start = 1;
                }
  if (( $start == 1 ) and ( $line =~m/\s*Sev\s*\:\s*(\w+)\s+\w+\s*\:\s*(\d+)\s*$/ )){
#                  $ref->{$1}->{ ${id} } = $2;
                 if ($1 eq 'Er'){
    $ref->{$cnt}->{num_errors} += $2 ;
   }elsif($1 eq 'War'){
    $ref->{$cnt}->{num_warnings} += $2 ;
   }
                   $start = 0;
                }
     }
     close IN;
     
}

Please use codetags.

if you show input and expected output, it would be better to write shell script, since some knows shell only, some knows perl, as well as shell,awk,etc. if you do not tell us what you are trying to achieve, person who knows perl as well as shell also may not be able to answer you.

Hope you will understand.

We don't usually deal in covert operations. Please check your spelling when submitting questions :slight_smile: