[EMAIL PROTECTED] wrote:

> Hi all,
>
> 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);

Let's break up this line
split (/\s+/) # this is actually splitting the contents of $_ using \s+ as the 
delimiter
The bigger expression (split (/\s+/), $str_line) just returns the contents of 
$str_line.
Read through the documents on the comma operator (perldoc perlop, sub-section Comma 
Operator)
What you are getting is the content of $str_line as such.
This is what you want
my $user = (split (/\s+/, $str_line))[0];
You might also want to consider turning warnings on and add use strict to your code


>

>
>
> Any help would be appreciated
>
> Thanks in advance,
> Melissa
>
> ------------------------------------------------------------------------------
> This message and any attachment is confidential and may be privileged or otherwise 
>protected from disclosure.  If you have received it by mistake please let us know by 
>reply and then delete it from your system; you should not copy the message or 
>disclose its contents to anyone.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to