glen

Untitled

Apr 14th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. http://cpansearch.perl.org/src/MSULLAND/Device-USB-PCSensor-HidTEMPer-0.03/lib/Device/USB/PCSensor/HidTEMPer/TEMPer.pm
  2.  
  3. ...
  4.  
  5. use constant SUPPORTED_DEVICES => {
  6. 0x5b => {
  7. 'name' => 'HidTEMPerNTC',
  8. 'module' => 'Device::USB::PCSensor::HidTEMPer::NTC'
  9. },
  10. 0x58 => {
  11. 'name' => 'HidTEMPer',
  12. 'module' => 'Device::USB::PCSensor::HidTEMPer::TEMPer'
  13. }
  14. };
  15.  
  16.  
  17. ..
  18.  
  19. # This functions detects the correct object to be created and returned.
  20. # Returns undef if not supported device was found.
  21. sub _init_device
  22. {
  23. my $prototype = Device::USB::PCSensor::HidTEMPer::Device->new( $_[0] );
  24. - my $parameters = (SUPPORTED_DEVICES)[0]{$prototype->identifier()};
  25. + my $parameters = SUPPORTED_DEVICES->{$prototype->identifier()};
  26.  
  27.  
  28. return undef unless defined $parameters;
  29.  
  30. bless $prototype, $parameters->{module};
  31. return $prototype->init();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment