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

Re^6: Remove blank lines from REGEX output

by AnomalousMonk (Abbot)
on Feb 06, 2014 at 11:51 UTC ( #1073699=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Remove blank lines from REGEX output
in thread Remove blank lines from REGEX output

One can also take another tack and use a series of statements like

next if not proper_year($year); next if not proper_month($month_nr); next if not proper_day($day_in_month, $month_nr, $year);

which might be said to offer the best of both concision (it's self-documenting, or can be made so) and encapsulation (annual, monthly and daily proprieties defined in one place in their respective validation functions). This sort of approach is what I usually prefer if I have the opportunity to take a second pass at a program and consolidate.

Then there's the OO approach...


Comment on Re^6: Remove blank lines from REGEX output
Download Code
Re^7: Remove blank lines from REGEX output
by Laurent_R (Prior) on Feb 06, 2014 at 14:22 UTC
    Yes, you are right, this is probably better. As I said earlier, my example was not given as a proper way to validate dates, but only as an example of rules that are self-documenting or obvious to anyone and thus don't really need any comments

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (17)
As of 2015-07-02 18:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls