Listing 4: Perl support program to create edit_real.sed
+-----------------------start--------------------------------------+
# Filename is edit_real_sed_perl_s
#---------------------------------------------------------------
# Thie file creates the domain sed script via a perl program
#
perl /bin/display/edit_real_sed.perl
+-----------------------end----------------------------------------+
Actual Perl file to create edit_real.sed sed file.
+-----------------------start--------------------------------------+
#------------------------------------------------------------
# Filename = edit_real_sed.perl
# This program creates edit_real.sed script to be used by display_s.
# It helps figure out new domain names.
#
#------------------------------------------------------------
# Variable change section start.
$start_char_var="(";
$end_char_var =")";
$number_of_domains=3;
$domain_var[2] =".nwscc.sea06.navy.mil";
$domain_var[1] =".ssa.crane.navy.mil";
$domain_var[0] =".crane.navy.mil";
$default_screen=":0.0";
$flag_to_make_short_name="TRUE"; # Make Short name
#$flag_to_make_short_name="FALSE"; # Make Long name
$long_name=".ssa.crane.navy.mil";
# Variable change section end.
#------------------------------------------------------------
open(OUT, ">edit_real.sed");
printf(OUT "s/$start_char_var//\n");
printf(OUT "s/$end_char_var//\n");
# because of zero indexing subtract 1.
$number_of_domains = $number_of_domains - 1;
$default_starting = "#";
while ($number_of_domains >= 0 ) {
# Add default screen ending.
$domain_var[$number_of_domains] =
join("",$domain_var[$number_of_domains],$default_screen);
# Change all "."s for "\."s.
$domain_var[$number_of_domains] =~ s/\./\\\./g;
#printf("$domain_var\n");
# loop section.
$domain_len_var=length($domain_var[$number_of_domains]);
$count=$domain_len_var;
#printf("$domain_len_var\n");
while( $count > 4 ) {
# Check to make sure one of the "\" we put in does not end a line.
if (substr($domain_var[$number_of_domains],$domain_len_var-1,1) eq
"\\" ) {
chop($domain_var[$number_of_domains]);
$domain_len_var=length($domain_var[$number_of_domains]);
$count = $count -1;
}
if ( $count > 0 ) {
if ( $domain_var[$number_of_domains] ne "\\\." ) {
printf(OUT
"s/%s/%s/\n",$domain_var[$number_of_domains],$default_starting);
}
chop($domain_var[$number_of_domains]);
$domain_len_var=length($domain_var[$number_of_domains]);
$count = $count -1;
}
} # end while count.
$number_of_domains = $number_of_domains - 1;
} # end while domain.
# Replace default starting with default screen now.
if ( $flag_to_make_short_name eq "TRUE" ) {
printf(OUT "s/%s/%s/\n",$default_starting,$default_screen);
}
else {
printf(OUT
"s/%s/%s%s/\n",$default_starting,$long_name,$default_screen);
}
close(OUT);
+-----------------------end----------------------------------------+
|