my %SERVICE; open (INSTALL, "install.pl") or die "$!"; while () { if (/my\s+%SERVICE\s+=\s+\(\s*$/) { $read = 1; next; } # just in case there are some values on the first line if (/my\s+%SERVICE\s+=\s+\(\s*"([^"]+)"\s+=>\s+"([^"])\s*,/) { print "\t\"$1\"\t=> \"$2\",\n"; $SERVICE{$1} = $2; $read = 1; next; } if ($read) { # if there's something on the last line of the hash if (/"([^"]+)"\s+=>\s+"([^"])\s*\)\s*;/) { $service .= $1; last; } # if there's not if (/([^\)]\));/) { $service .= $1; last; } # or if we're not on the last line grab the values if (/"([^"]+)"\s+=>\s+"([^"]+)"\s*,\s*$/) { $SERVICE{$1} = $2 } } } close INSTALL; #### "/etc/rc2.d/S88sendmail" => "Sendmail",