I've survived with Perl so far, but I'm starting to stretch myself now, and my lack of knowledge is starting to let me down. I'm trying to produce a page that when the user clicks on a button, the script gets called, but the page doesn't change. Basically the script triggers an MP3 to play on the server, but I want to keep the screen the same so the user can click around the different sounds.
At the moment the sound starts, but the page then tries to load something and then sits there till the track finishes, when I get an error 500. I'm guessing this is something to do with qx, but I'm not sure. Can anyone help.
Thanks
At the moment the sound starts, but the page then tries to load something and then sits there till the track finishes, when I get an error 500. I'm guessing this is something to do with qx, but I'm not sure. Can anyone help.
Thanks
Code:
#!/usr/bin/perl
# Parse the passed data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$temp = trim($FORM{'Track'});
$Track = "/home/jellyd/play.sh -f $temp"; # Command construction
qx[$Track]; # Call the mp3 script
exit 0;
# Removes leading and trailing spaces
sub trim {
my @out = @_;
for (@out)
{
s/^\s+//;
s/\s+$//;
}
return wantarray ? @out : $out[0];
}