#!/usr/bin/perl use strict; use warnings; use IO::Socket; my $bulb_sock = IO::Socket::INET->new( Proto => 'udp', PeerPort => 50000, PeerAddr => '192.168.1.8', ) or die "Could not create socket: $!\n"; $bulb_sock->send("\x22\x02\x55") or die "Send Error: $!\n"; my $variable; for (my $i=1 ; $i<3 ; $i++) { $variable = "\x21"."$i"."\x55"; $bulb_sock->send("$variable") or die "Send Error: $!\n"; }