This worked fine for me!
$_ = "nobody Wed Aug 22 12:32:22 2001 I";
print "$_\n";
$_ =~ s/^(.{7})\s+?(.{24})\s+?(\S+)$/$1,$2,$3/;
print "User = $1\n";
print "Date = $2\n";
print "State = $3\n";
John Way
GoodleafJ@imm
unex.com To: [EMAIL PROTECTED]
cc:
09/04/2001 Subject: regex: can't match pattern...
dang
01:10 PM
I posted a similar question last week; this is a rephrasing.
I have the following strings:
root Wed Aug 22 04:44:59 2001 DLs
root Wed Aug 22 04:44:59 2001 ILs
root Wed Aug 22 04:44:59 2001 DL
root Wed Aug 22 04:44:59 2001 DL
root Wed Aug 22 04:44:59 2001 DL
root Wed Aug 22 04:44:59 2001 DL
root Wed Aug 22 04:46:37 2001 Is
root Wed Aug 22 11:46:38 2001 Ss
root Wed Aug 22 11:46:39 2001 Ss
daemon Wed Aug 22 11:46:40 2001 Is
root Wed Aug 22 11:46:41 2001 Is
root Wed Aug 22 11:46:41 2001 Ss
root Wed Aug 22 11:46:41 2001 Is
root Wed Aug 22 12:31:21 2001 Is
postfix Wed Aug 22 12:31:21 2001 I
root Wed Aug 22 12:32:21 2001 Ss
nobody Wed Aug 22 12:32:21 2001 I
nobody Wed Aug 22 12:32:22 2001 I
nobody Wed Aug 22 12:32:22 2001 I
nobody Wed Aug 22 12:32:22 2001 I
I want three things:
user, the entire date, the state.
I'm currently trying to get this with:
for(@procs){
/^(.{7})\s+?(.{24})\s+?(\S+?)$/;
I want $1 to be the user (e.g. 'root' 'postfix').
I want $2 to be something like 'Wed Aug 23 05:30:01 2001'.
I want $3 to be the state, which was a lot of forms, but which is, for
example 'DLs' above.
Shouldn't this get the first 7, then 24 characters, then the glop that's
left over?
What am I doing wrong?
-John
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
**** Confidentiality Notice: *******************************************
Privileged/Confidential information may be contained in this message
and is intended only for the use of the addressee. Please advise
immediately if you or your employer do not consent to Internet e-mail
for messages of this kind. If you are not the addressee, or person
responsible for delivering to the person addressed, you may not copy or
deliver this to anyone else. If you receive this message by mistake,
please notify the sender immediately by return e-mail. Thank you.
************************************************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]