1752672 Members
6111 Online
108789 Solutions
New Discussion юеВ

Re: Logic required.

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: Logic required.

Hi:

> Dennis: Perhaps the input needs to be sorted, or the absolute value used.

Of course. And if we had a better problem definition, the necessity or lack thereof would be clear.

Since Perl has an 'abs()' function one could change:

if ( ($delta = $time2-$time1) >= $mindelta ) {

..to:

if ( ($delta = abs($time2-$time1)) >= $mindelta ) {

...

However, a clearer problem statement eliminates the guessing.

Regards!

...JRF...
Hein van den Heuvel
Honored Contributor

Re: Logic required.

The script I presented in an earlier reply worked just fine with the crappy sample data, as it ignored the date.
Grins,
Hein
Archana1
Frequent Advisor

Re: Logic required.

Hello JRF,

Thanks for your script its my typo in scrap log file. Apologies for same.

$ more log.out
2010-11-18 02:13:36.832|Warning|PipelinePairNode for fraudCheckResultAdd :: Pipe
linePairNode for fraudCheckAdd _response:: Generate native response for Tuxedo::
RESPONSE| Before Receipt Of Final Fraud Decision: 1F2504E0-4F89-11D3-9A0C-0305E
82C3301
2010-11-18 04:13:39.345|Warning|PipelinePairNode for fraudCheckResultInq :: Pipe
linePairNode for fraudCheckResultInq _response:: Generate native response for Tu
xedo:: RESPONSE| Before Receipt Of Final Fraud Decision: 1F2504E0-4F89-11D3-9A0C
-0305E82C3301
Delta = 7203


Is this expected in log.out

Iam glad that I started learning perl scripting now..
James R. Ferguson
Acclaimed Contributor

Re: Logic required.

Hi:

> Is this expected in log.out

Yes. I assumed that you wanted to log the pair of records that triggered meeting the condition (a time difference greater than or equal to '$mindelta' written to the output. I added the time difference too.

As I originally noted, you can run the script passing the input file as an argument and redirecting the STDOUT stream to a file:

# ./myscript logfile > log.out

Regards!

...JRF...
Archana1
Frequent Advisor

Re: Logic required.

Hi JRF,
One more concern, when I test with real log file below are the messages and log.out is empty.

$ ./myscript app > log.out
Use of uninitialized value in numeric gt (>) at ./myperl line 14, <> line 10.
Use of uninitialized value in numeric gt (>) at ./myperl line 14, <> line 20.
Use of uninitialized value in numeric gt (>) at ./myperl line 14, <> line 30.


Appreciate your time. Seeming script tweaking is required.
James R. Ferguson
Acclaimed Contributor

Re: Logic required.

Hi:

> when I test with real log file below are the messages and log.out is empty.

The output is null because there are no "fraudCheckResultAdd" records.

As for the warnings from Perl, I should have initialized the variables. Change:

my ( $line1, $line2, $delta, $time1, $time2 );

...to:

my ( $line1, $line2, $delta, $time1, $time2 ) = ( '', '', 0, 0, 0 );

...

Haste makes waste :-)

Regards!

...JRF...