> EDIT:
> system("$editor $edopts $tmpfile");
>
> QUERY:
> print "\nsend, continue editing, discard [s,c,d]? ";
> $ans = <STDIN>;
>
> if ($ans =~ /^\s*[Ss]/ ) { &send($tmpfile); }
> elsif ($ans =~ /^\s*[Dd]/ ) { &discard($tmpfile); }
> elsif ($ans =~ /^\s*[Cc]/ ) { goto EDIT; }
> else { goto QUERY; }
1. What is the possibility of this being added in the future?
2. What is the best way to recode around this? Put in blocks
after each label and s/goto/next/?
Thanks in advance,
Mark.
--
Mark Harrison | Note: harr...@ssd.dl.nec.com and
harr...@csl.dl.nec.com | necssd!harrison are not operating at
(214)518-5050 | present. Please forward mail through the
| above address. Sorry for the inconvenience.
In the near future, the probability is close to zero. In the distant
future, I'll be dead, and posterity can do whatever they like... :-)
: 2. What is the best way to recode around this? Put in blocks
: after each label and s/goto/next/?
There are two basic ways to do do state diagrams in Perl. Both involve
keeping a state variable. One way uses the state variable in a case
structure inside a loop:
while ($state ne 'EXIT') {
$state eq 'EDIT' && do {
...
};
$state eq 'QUERY' && do {
...
};
}
The other way just calls out to subroutines based on the state:
while ($state ne 'EXIT') {
&$state;
}
sub EDIT {
...
}
sub QUERY {
...
}
I prefer the latter.
Larry