#  DumpEventSources.pl
#  Example 5.1:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script displays the logon script path for the specified
#  user accounts.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


use Win32::EventLog::Message;

$LogName = lc shift @ARGV || die "Syntax:\n$0 <Event Log Name> [source [source2 [...] ] ]\n";
print "\u$LogName Event Log:\n";

$~ = MessageLogHeader;
write;

$~ = MessageLogPath;

if( scalar @ARGV )
{
    push( @List, @ARGV );
}
else
{
    GetSourceList( $LogName, \@List );
}

$Num = 0;
foreach $Name ( sort( @List ) )
{
    if( GetSource( $LogName, $Name, \%Config ) )
    {
        $Num++;
        $Path = join( " " x 30, split( /[,;]/, $Config{path} ) );
        write;
    }
}

format MessageLogHeader =
  @>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  "Count", "Source Log Name",            "Path To Message Table"
  ----- ---------------------------- ------------------------------------------
.

format MessageLogPath =
  @>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  $Num, $Name,                      $Path
~                                   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                    $Path
~                                   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                    $Path
~                                   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                    $Path
~                                   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                    $Path
~                                   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                    $Path
.
