I
ian
Cut un paste and you will see the problem
Code comment shows what I can't do !!
NOTE! DATA is 2 (TWO) lines only.
#!/usr/bin/perl
my $n = "\n";
while ( <DATA> ) {
chomp;
my ( @bu ) = $_ =~ m{
.*
(\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d)
.\d*\s
([\w]*)[\W]
(.*-\s*)
(Returning\sfrom|Entering)\s* #
Should be able to get 1 or n words
([\w._]+)
# Problem Area !!
(?:
(\(.*\))
|
(\(.*\))
(,\s+[\w]+:\s+)
(.*)
)
}x;
my $c = 0;
for my $q ( @bu ) {
$c++;
printf "%2s '%s'\n", $c, $q;
}
print $n;
next;
}
print "-----------".$n;
# RETURNS:-
#
# 1 '2009-09-01 15:58:51'
# 2 'INFO'
# 3 ' [ com.manager ] - '
# 4 'Entering'
# 5 'get.Prod_Codes'
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST)'
# 7 ''
# 8 ''
# 9 ''
#
# 1 '2009-09-01 15:58:51'
# 2 'INFO'
# 3 ' [ com.manager ] - '
# 4 'Returning from'
# 5 'get.Prod_Codes'
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST),
result: id:017661, productCodes: [GEAR | BOX | TARGET (2000)]
, Descn: [Mechan | Type 1 (2000)'
# 7 ''
# 8 ''
# 9 ''
#
#-----------
# BUT WANT the return from to look like:-
# . . . . . .
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST)
# 7 ', result: '
# 8 '(id:017661, productCodes: [GEAR | BOX | TARGET (2000)], Descn:
[Mechan | HARDENED | Type 1 (2010) ])'
#
__DATA__
Server.log:2009-09-01 15:58:51,513 INFO [ com.manager ] - Entering
get.Prod_Codes( id:017661, date: Tue Sep 01 15:58:51 CEST 2009,
instance:TEST)
Server.log:2009-09-01 15:58:51,531 INFO [ com.manager ] - Returning
from get.Prod_Codes( id:017661, date: Tue Sep 01 15:58:51 CEST
2009, instance:TEST), result: id:017661, productCodes: [GEAR | BOX |
TARGET (2000)], Descn: [Mechan | HARDENED | Type 1 (2010) ]
)
Code comment shows what I can't do !!
NOTE! DATA is 2 (TWO) lines only.
#!/usr/bin/perl
my $n = "\n";
while ( <DATA> ) {
chomp;
my ( @bu ) = $_ =~ m{
.*
(\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d)
.\d*\s
([\w]*)[\W]
(.*-\s*)
(Returning\sfrom|Entering)\s* #
Should be able to get 1 or n words
([\w._]+)
# Problem Area !!
(?:
(\(.*\))
|
(\(.*\))
(,\s+[\w]+:\s+)
(.*)
)
}x;
my $c = 0;
for my $q ( @bu ) {
$c++;
printf "%2s '%s'\n", $c, $q;
}
print $n;
next;
}
print "-----------".$n;
# RETURNS:-
#
# 1 '2009-09-01 15:58:51'
# 2 'INFO'
# 3 ' [ com.manager ] - '
# 4 'Entering'
# 5 'get.Prod_Codes'
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST)'
# 7 ''
# 8 ''
# 9 ''
#
# 1 '2009-09-01 15:58:51'
# 2 'INFO'
# 3 ' [ com.manager ] - '
# 4 'Returning from'
# 5 'get.Prod_Codes'
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST),
result: id:017661, productCodes: [GEAR | BOX | TARGET (2000)]
, Descn: [Mechan | Type 1 (2000)'
# 7 ''
# 8 ''
# 9 ''
#
#-----------
# BUT WANT the return from to look like:-
# . . . . . .
# 6 '( id:017661, date: Tue Sep 01 15:58:51 CEST 2009, instance:TEST)
# 7 ', result: '
# 8 '(id:017661, productCodes: [GEAR | BOX | TARGET (2000)], Descn:
[Mechan | HARDENED | Type 1 (2010) ])'
#
__DATA__
Server.log:2009-09-01 15:58:51,513 INFO [ com.manager ] - Entering
get.Prod_Codes( id:017661, date: Tue Sep 01 15:58:51 CEST 2009,
instance:TEST)
Server.log:2009-09-01 15:58:51,531 INFO [ com.manager ] - Returning
from get.Prod_Codes( id:017661, date: Tue Sep 01 15:58:51 CEST
2009, instance:TEST), result: id:017661, productCodes: [GEAR | BOX |
TARGET (2000)], Descn: [Mechan | HARDENED | Type 1 (2010) ]
)