Now I'm confused, I thought a substr would be faster than a regex in this
case as the data is formatted.
Would it?
-
#!/usr/bin/perl -w
use strict;
while ( ) {
my $user = substr($_, 0,8);
my $date = substr($_, 9,32);
my $state = subst
[EMAIL PROTECTED] wrote:
>
> I posted a similar question last week; this is a rephrasing.
>
> I have the following strings:
>
> [snip data]
>
> I want three things:
>
> user, the entire date, the state.
>
> I'm currently trying to get this with:
>
> for(@procs){
> /^(.{7})\s+?(.{24})\s+?(\
On Tue, Sep 04, 2001 at 10:10:39AM -0700, [EMAIL PROTECTED] wrote:
> rootWed Aug 22 04:44:59 2001 DLs
[snip]
> 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
Which works with or without leading or trailing spaces. It also tidies up the
regex and doesn't hand you a user name padded to 7 characters with spaces (which
yours would, if it worked).
HTH,
Rob
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>
Good day;
I have the following strings:
> rootWed Aug 22 04:44:59 2001 DLs
>I want three things:
>
>user, the entire date, the state.
What is separating these attributes? A constant number of spaces, or a tab?
If so, it might be easier to use the "split" function.
($user, $date, $
unex.com To: [EMAIL PROTECTED]
cc:
09/04/2001 Subject: regex: can't match pattern...
dang
I posted a similar question last week; this is a rephrasing.
I have the following strings:
rootWed Aug 22 04:44:59 2001 DLs
rootWed Aug 22 04:44:59 2001 ILs
rootWed Aug 22 04:44:59 2001 DL
rootWed Aug 22 04:44:59 2001 DL
rootWed Aug 22 04:44:59 2001 D