Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Cheap idioms

by Aragorn (Curate)
on Oct 13, 2002 at 17:35 UTC ( #204924=note: print w/replies, xml ) Need Help??


in reply to Cheap idioms

Nicely small and concise. I'd only use this in stand-alone scripts, because there aren't any checks on file existence, etc. Burying this kind of code inside libraries is asking for trouble... :-)

Replies are listed 'Best First'.
(tye)Re2: Cheap idioms
by tye (Sage) on Oct 13, 2002 at 17:49 UTC

    Actually, part of the beauty of this idiom is that you get Perl itself to check for file existence and to report better than average error messages.

                    - tye
      Oh, I like this idiom, but strictly in stand-alone scripts. Bombing out of a program deep inside some library doesn't sit well with me.

      And Perl exits with the following error message if the file doesn't exist using this idiom:
      Can't open /does/not/exist: No such file or directory.
      Uhm. I can do that :-)

        Yes, it doesn't seem hard at all does it? (:

        It includes a description of what was being attempted ("open", though I'd probably opt for metioning that "read" access is what was required -- though I can understand not wanting to confuse people into thinking it was a read operation that failed while keeping the message short), the input data to the operation (the name of the file), and the correct error code indicating why it failed ($! in this case).

        Unfortunately, that still makes it above average in my experience. ):

                - tye (who doesn't like error messages a la mode)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://204924]
help
Chatterbox?
[ambrus]: You hvae to be careful with the timer, because apparently Prima::Timer insists on being periodic, wheras AnyEvent::Impl:: Whatever::timer should give a one-shot timer watcher
[ambrus]: I think the minimal implementation here is just a timer and io function, plus pushing to the @REGISTRY.
[Corion]: ambrus: Yeah, at least that's what I think I'll start with. A timer and potentially the dummy IO function that never is ready
[ambrus]: That only lets you invoke the main loop from Prima->run;, not from AnyEvent->condvar- >recv; but that shouldn't matter

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













    Results (141 votes). Check out past polls.