Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: File handles and loops

by anazawa (Scribe)
on Jul 31, 2012 at 08:24 UTC ( #984582=note: print w/replies, xml ) Need Help??


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 }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984582]
help
Chatterbox?
[Corion]: choroba: Optimizing how Perl reads source code on startup (and then processes it line-by-line)
[Corion]: But in general, it seems to be an interesting approach I should think about - whenever I'm searching for something, to consider if I could search for the end of the token instead of the start of the token

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2016-12-06 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (108 votes). Check out past polls.