Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Short or Long Hand

by rsteinke (Scribe)
on Aug 12, 2004 at 15:19 UTC ( [id://382287]=note: print w/replies, xml ) Need Help??


in reply to Short or Long Hand

Not so useful for a short list like this with only two elements, but

if(not @{[grep {$day == $_} (0,6)]}) { # foo }
Not much of a gain here, but imagine if the list were 20-30 elements.

Ron Steinke
<rsteinke@w-link.net>

Replies are listed 'Best First'.
•Re^2: Short or Long Hand
by merlyn (Sage) on Aug 12, 2004 at 16:04 UTC
      I like that. Although it's a good argument for something like an in operator. if ($day in (0,6)) is (to me) much cleaner in meaning, even if it's just syntactic sugar for the grep.
Re^2: Short or Long Hand
by Scarborough (Hermit) on Aug 12, 2004 at 15:26 UTC
    I like that one, I have a use for that when I'm working out my month end dates which in my case are not always the last day of the month.
    Thanks
      If you are doing much date manipulation at all, you should strongly consider using one of the fine modules available: DateTime, Date::Calc, Date::Manip, etc. There isn't much learning curve; most have FAQs with cut-and-paste recipes for common tasks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found