#!/usr/bin/perl use common::sense; use IO::Socket; use IO::Select; # establish connection my $socket = IO::Socket::UNIX->new( Peer => '/path/to/socket.file.sock', ); my $sel = IO::Select->new(); $sel->add($socket); # issue command and read answer my $some_command = 'foo'; print $socket "$some_command\n"; my $html = "". sockread($sel,$socket). ""; sub sockread { my $sel = shift; my $socket = shift; my $content; my $TimeOut = 0.5; #sec to wait while ($sel->can_read($TimeOut) && (my $line=<$socket>)){ $content .= $line; last if $line =~ /\[ End of /i; # vlc's rc is a bit inconsistent, some end like this last if $line =~ / returned 0 /i; # others like this } return $content; }