Options

Need help convert Perl to Bash

estipomestipom Member Posts: 22 ■■■□□□□□□□
$LO1_configured = "Not Present";
    $LO2_configured = "Not Present";
    $HN_configured = ();
    for $i (0..$#ips) {
      $HN_configured{$i} = "Not Present";
    }
    $hfile = "/etc/hosts";
    open(HOSTS,$hfile) or print "Could not open $hfile \n";
    while(<HOSTS>) {
      chop;
      ($name,$value,$rest) = split(/\s+/);
      if ($name eq "127.0.0.1" && $value eq "localhost") {
        $LO1_configured = "Present";
      } elsif ($name eq "127.0.0.2") {
        $LO2_configured = "Present";
      } else {
        for $i (0..$#ips) {
          if (($ips[$i] eq $name)&&( $value ne "")) {
            $HN_configured{$i} = "Present";
          }
        }
      }
    }
     
    close(HOSTS);


i do not know much about Perl, can you help me translate this into Bash? Thanks
Sign In or Register to comment.