Thread Platformunabhängigen code UNIX/Win32
(7 answers)
Opened by Schnullux at 2008-07-24 18:04 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 package MyLogger; use strict; use warnings; sub new { if( $^O =~ /win32/i ){ require MyLogger::Win32; return MyLogger::Win32->new; } else{ require MyLogger::Default; return MyLogger::Default->new; } } 1; Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 package MyLogger::Win32; use strict; use warnings; use all_Win32_stuff; sub new{ my ($class) = @_; my $self = bless {}, $class; $self->{handle} = Win32::EventLog->new("Zaphod"); } sub log { my ($self) = @_; my %win; $win{'Computer'} = "Eddy"; $win{'Source'} = "Hard of Gold"; $win{'Category'} = undef; $win{'EventID'} = 42; $win{'Data'} = undef; $win{'Strings'} = "Dont interrupt me, I computing real earth Tee!" $self->{handle}->Report(\%win); } ... Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package MyLogger::Default; use strict; use warnings; use all_Unix_stuff; sub new{ my ($class) = @_; return bless {}, $class; } sub log { &syslog(LOG_DEBUG,"Where is Marvin??"); } ... OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |