Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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?
erix clocks 12 years
[TStanley]: talexb I was actually in your area last week. I was working in Milton, Ontario at the hospital they are building there.
Eily hasn't entered monk school
[Eily]: there are some special array variables that are not interpolated in double strings, like @*, @/, @(, and @)
[Eily]: is this documented somwhere?
[Eily]: "@{/}" does interpolate @/ though

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-06-23 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (547 votes). Check out past polls.