Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: Not able to capture information

by oko1 (Deacon)
on Feb 17, 2012 at 07:52 UTC ( #954431=note: print w/replies, xml ) Need Help??

in reply to Re: Not able to capture information
in thread Not able to capture information

My 2 cents on your 2 cents: validating user input is very simple. Never try to "enumerate badness"; just define what is valid and reject everything else.

my $in; { print "Input 'foo': "; chomp($in=<STDIN>); redo unless /^foo$/; }
I hate storms, but calms undermine my spirits.
 -- Bernard Moitessier, "The Long Way"

Replies are listed 'Best First'.
Re^3: Not able to capture information
by Marshall (Abbot) on Feb 17, 2012 at 09:02 UTC
    I don't think that we need to get into a big discussion in the context of this thread.

    Part of what I'm saying is that with:
    [2012/02/16 00:08:34] [29] ERRORMSG unknown error

    There is no reason or need to parse the date time format with some huge regex eg:

    If the line begins with "[" it is a date/time and there is no reason to parse or otherwise try to understand it. Maybe this changes to YYYY-MM-DD or YYYY.MM.DD instead of YYYY/MM/DD? In the context of this re-formatting program, it shouldn't matter.

    Basically, if a complex regex is not essential to the program operation, don't even do that. Here all that is needed is to understand that the square brackets on the first part of a line signifies a "new record". Past that, the parser shouldn't care about the format between the square brackets, because it doesn't need to do that in order to do its job!

    Maybe we are actually in agreement here?
    ^[...] starts a new "message line" and that is all we need to know - that is considered "valid input" no matter what is between the [...].

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://954431]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-03-19 20:23 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.