Kevin wrote:
> 
> Hi
> 
> I have a really simple problem that I could solve easily with a strstr() call
> in c but cannot get my head around in perl.
> 
> I have have the following input.
> 
> Active Accounted actions on tty57, User fred Priv 1
>  Task ID 35176, Network Accounting record, 02:04:00 Elapsed
> 
> what I want to do is
> 
>    for $data (@raw_data){
>         if $data contains "User"

something like
if ($data =~ /User ([^ ]*)/)
{
  $username = $1;
}

what happends there is that it checks for the occurance of User then a
space followed by 0-* nonspace chars. it puts the nonspace cars, ie the
username in $1 since we hve the () around that part.

you should read the documentation at 'perldoc perlre' and/or read books
about perl. My guess is that it'd take you 5 mins of reading in learning
perl to solve this problem.

/Jon


>                 $username = [the word after User];
>    }
> 
> The length of this string can vary so I cannot rely on "User" being at n
> charcters from beginning or end of string.
> 
> I am sure it is a RegEx problem but any help/pointers appreciated.
> 
> Thanks
> 
> Kevin
> 
> --
> 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