newbie: foreach



I'm sure the below can be simplified with some sort of "foreach", but
so far I've failed. Anyone help please?
Snippet of code attached:

#######################################################################
# Display prompt; push the partial line of text to the console
proc yes_no {userlib} {
puts -nonewline "Do you want $userlib Libraries (enter Y/N)? "

flush stdout
# Loop until we have satisfactory input
while {1} { #loop forever until told to stop
gets stdin line
set ans [string tolower [string index $line 0]]
if {$ans == "y"} {
set yes 1
break ;# get out of while loop
} elseif {$ans == "n"} {
set yes 0
break ;# get out of while loop
} else {
puts -nonewline "Try again: $userlib Libs (Y/N)? "
flush stdout
}
}
return $yes
}
#######################################################################

set yes_Actel_apa [yes_no Actel_apa]
set yes_Actel_act1 [yes_no Actel_act1]
set yes_Actel_act2 [yes_no Actel_act2]
set yes_Actel_act3 [yes_no Actel_act3]


if {$yes_Actel_apa == 1} {
puts $hdsnew "apa = C:/Actel/MS57e_D61_SP1/lib/vtl/95/mti/apa"
}
if {$yes_Actel_act1 == 1} {
puts $hdsnew "act1 = C:/Actel/MS57e_D61_SP1/lib/vtl/95/mti/act1"
}

if {$yes_Actel_act2 == 1} {
puts $hdsnew "act2 = C:/MS57e_D61_SP1/lib/vtl/95/mti/act2"
}

if {$yes_Actel_act3 == 1} {
puts $hdsnew "act3 = C:/MS57e_D61_SP1/lib/vtl/95/mti/act3"
}

.



Relevant Pages

  • Re: Perl Script - Not Getting Results When Using Command Line Arguments
    ... #Sixth section provides dirlist in wide format for another directory. ... @SORTED_DIRLIST = sort @DIRLIST; ... foreach $result ... This filetest won't work. ...
    (perl.beginners)
  • Re: how to use xml::simple with nested for loops???
    ... Going back a couple weeks regarding the nested foreach to read out nested ... But a new requirement is that I sort the output ... $xml is a scalar that contains a reference to an anonymous hash ... "FOREST". ...
    (perl.beginners)
  • Re: Perl Script - Not Getting Results When Using Command Line Arguments
    ... #Help file provides command usage in event of error. ... @SORTED_DIRLIST = sort @DIRLIST; ... foreach $result ... #Fifth section provides dirlist in wide format for current directory. ...
    (perl.beginners)
  • Re: I dont understand loop count
    ... Printing problems are the most *obvious* kind to debug. ... you are printing at each interation of the foreach loop!) ... The regex line in your code is useless. ... Is this asterisk some sort of secret code I'm missing here? ...
    (comp.lang.perl.misc)
  • Re: Sorting dir output
    ... foreach my $afile { ... unlink($afile) or warn "Cannot delete $afile. ... How could I exec a 'dir' command on a dos system and put the output in ... sort by date and the files that are older than 3 days be moved ...
    (perl.beginners)