you can use lookaheads:

my @matched = split /\s+(?=\w+=)/,$string;

cheers,
~i

On 1/19/07, Michael Alipio <[EMAIL PROTECTED]> wrote:
Hi,

Suppose I have:


my $string = 'Jan 19 11:37:21 firewall date=2007-01-19 time=11:42:15 
devname=TESTfirewall device_id=FGT-602905503304 log_id=0104032006 ty
pe=event subtype=admin pri=information vd=root user="admin" ui=GUI(192.168.1.1) 
action=login status=success reason=none msg
="User admin login successfully from GUI(192.168.1.1)"
';


That is, on a regular \s+ split, I will produce this list of strings:
Jan
19
11:37:21
firewall
date=2007-01-19
time=11:42:15
devname=TESTfirewall
device_id=FGT-602905503304
log_id=0104032006
type=event
subtype=admin
pri=information
vd=root
user="admin"
ui=GUI(192.168.1.1)
action=login
status=success
reason=none
msg="User
admin
login
successfully
from
GUI(192.168.1.1)"

However, I only want to split it with \s+ as delimiter, only if that \s+ is followed by 
"\w+=" so that the: 'msg="User admin login successfully from GUI(192.168.1.1)" 
will not be splited.

I tried putting parenthesis in my split pattern:

split/(\s+)\w+=/, $_

So that it will only split the line delimited by space if it is followed by any 
"\w+=" just like when doing a regexp matching.
But the program treats \w+= as part of the whole pattern so instead of getting:

date=2007-01-19

time=11:42:15

devname=TESTfirewall

device_id=FGT-602905503304


I got:

2007-01-19

11:42:15

TESTfirewall

FGT-602905503304


Any idea how to accomplish my goal?









____________________________________________________________________________________
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to