in reply to
File handles and loops
Your problem interests me :) AnyEvent will help you manage loops:
use strict;
use warnings;
use AnyEvent;
my $file = 'my_file.txt';
my $cv = AnyEvent->condvar;
print "start editing $file ... Ľn";
# main loop
my $reader = AnyEvent->io(
fh => \*STDIN,
poll => 'r',
cb => sub {
system( 'vim', $file );
if ( is_valid( $file ) ) {
print "File is okĽn";
$cv->send; # exits "main loop"
}
else {
print "Hit return to continueĽn";
}
},
);
# enters "main loop" till $cv gets ->send
$cv->recv;
sub is_valid {
# validate my_file.txt here
}