Connie Chan wrote:
> 
> From: <[EMAIL PROTECTED]>
> >
> > I have the following data stored in a variable ($str_line), but I only
> need the usernames (ie the first column) from this information.  How do i
> extract just the user names?
> >
> > aragonm 172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54
> > salibaj     172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54
> > seniorb    172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54
> >
> > This is what I am currently using, but it just returns all the
> information.
> >
> > my $user = (split (/\s+/), $str_line);
> 
> my @usrList = ();
> 
> for (@log)
> {  s/^(\w+) /$1/;

The only thing that this does is remove a space character after the
first word.

$ perl -le'
$_ = "aragonm 172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54";
print;
s/^(\w+) /$1/;
print;
'
aragonm 172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54
aragonm172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54


>     @usrList = (@usrList, $_);

You should never do this in a real program, it is very inefficient.

    push @usrList, $1 if /^(\S+)/;


> }
> 
> @usrList may be what you want...



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to