View Full Version : Perl Newbie... What's wrong ?

2010-01-27, 17:07
Hi All

Been a while since I've been on here - show's how robust these little players are ! - but I'm trying my hand at some Perl hacking (never done perl before, so please be gentle :) )

I've recently bought a new Onkyo NR807 amp which has an ethernet interface for controlling the receiver. I've knocked up some sample perl scripts which turn the player on / off and switch inputs etc.

Ok... I know there's the IR blaster plugin, but I thought I'd have a stab at modifying the code in the plugin to call my scripts. Plus, it gets rid of the dangling IR blaster blu-tacked to the front of my nice new shiny amp !

Now, after I've made my changes, the plugin refuses to load when SqueezeCenter is restarted... no idea why, the logs aren't really that helpful :( ...

[10-01-27 17:22:08.9856] Slim::Utils::PluginManager::enablePlugins (493) Error: Couldn't load Plugins::IRBlaster::Plugin

My changes (and this is my first time with perl as I've already said) are basically this for powering on the amp :

use IO::Socket;

my $sock = new IO::Socket::INET (
PeerAddr => '',
PeerPort => '60128',
Proto => 'tcp',
die "Could not create socket: $!\n" unless $sock;


$code =chr($length);

$line = "ISCP\x00\x00\x00\x10\x00\x00\x00$code\x01\x00\x00\ x00".$cmd."\x0D";
print $sock $line;
$line = "ISCP\x00\x00\x00\x10\x00\x00\x00$code\x01\x00\x00\ x00".$cmd."\x0D";

print $sock $line;

I tested from a command line (windows xp running ActivePerl) and it works just fine, however, if I mod the 'Plugin.pm' file for the IRBlaster plugin...

1. place 'use IO::Socket;' at the top of the file by the rest of the 'use' statements

2. In the 'sub handlePowerOnOff {' routine, I place my power-on code where the status is checked (not including the 'use IO::Socket' line obviously.. but the rest exactly as typed above).

- nothing ! well, not suprising as the plugin refuses to load.

Any one care to give this perl newbie a few pointers where I could be going wrong ?



2010-01-27, 21:19
You should start Squeezebox Server with the parameter: --d_startup

This will show more descriptive error messages at the startup if something fails.

It's hard to say exactly what's wrong without actually running it with --d_startup so you see the whole error but I'm guessing the plugin has a "use strict" at the top, if it does I think you need to use "my " before each variable on the first row it's mentioned. For example:
my $cmd="!1PWR01";
Instead of: