As a newcomer to perl, I'm trying to figure out the best way of doing the following.
I have an error log file . Here's a sample
00:00000:00014:2005/11/30 10:01:23.77 server Configuration file '/opt +/sybase/SERVER1.cfg' has been written and the previous version has been renamed to '/opt/sybase/SERV +ER1.030'. 00:00000:00014:2005/11/30 10:01:23.80 server The configuration option + 'log audit logon success' has been ch anged by 'sa' from '0' to '1'. 00:00000:00015:2005/11/30 10:01:37.36 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00016:2005/11/30 10:10:50.91 Logon Login succeeded. User: xy +z, Client IP address: '169.123.26.124'. 00:00000:00017:2005/11/30 16:31:31.02 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00020:2005/11/30 16:51:11.90 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00021:2005/12/01 09:49:23.44 Logon Login succeeded. User: ab +c, Client IP address: '169.123.26.124'. 00:00000:00022:2005/12/01 09:49:23.90 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00023:2005/12/01 09:51:29.65 kernel Cannot read, host proces +s disconnected: SERVER1 spid: 23 00:00000:00025:2005/12/01 09:52:27.74 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00026:2005/12/01 09:55:24.06 Logon Login succeeded. User: qw +r, Client IP address: '169.123.26.124'. 00:00000:00027:2005/12/01 09:55:47.15 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00026:2005/12/01 10:02:25.95 server Configuration file '/opt +/sybase/SERVER1.cfg' has been written and the previous version has been renamed to '/opt/sybase/SERV +ER1.031'.
I need to be able to extract the records which have "Login succeeded" but specifically only the user name from that record. e.g. sa, xyz, abc,qwr

I actually just need one occurence of each different user that has successfully logged in. So in the above snippet sa has logged in several times but all I need to know is that they have logged in at least once
I started off by doing this

use strict; my $line; my @array; # Open the errorlog file open(errlog,"/opt/sybase/logs/errorlog_SERVER1") or die "Can't open er +rorlog file!"; # Open th eoutput file open(loginf,">/tmp/login.dat"); while ($line = <errlog>) { chomp $line; next unless ($line =~ /Login succeeded/); push @array, $line; } foreach (@array) { print "$array[7]\n"; } close errlog; close loginf;
This just prints the whole line out. I was under the impression that the array is naturally split by a space ?
Anyhow , how do I get just one distinct occurence of each user into another file ?
Thanks

In reply to array processing by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.