Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Write "Dumber" Functions

by Juerd (Abbot)
on Mar 30, 2002 at 18:41 UTC ( [id://155465]=note: print w/replies, xml ) Need Help??


in reply to Write "Dumber" Functions

It appears that calling the check_date method with anything other than three arguments, such as the case when the @date array above is empty, the module dies with the suggested function usage and arguments.

Fortunately, you can catch the error by using eval (remember: eval STRING is slow (and evil), eval BLOCK is not.). If check_date succeeds, it will still return true. (Eval returns the whatever its string or block returns - which is the last evaluated value if there's no explicit return)

unless (eval { check_date @date }) {

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://155465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found