in reply to pass subroutine value to scalar

I assume you're trying to get the return value of your system command, "xmmsctrl print %T", and not simply the return value of your sub named ctrl(). After all, the return value of ctrl() is going to be the return value of your print command, which is pretty much always '1'. You might be looking for the backticks( `` ) operator (also spelled as qx//) instead of system.

The following snippet captures the output of xmmsctrl print %T and returns via ctrl() to $ctrl.

use strict; sub ctrl { my $rv = `xmmsctrl print %T`; return $rv; } my $ctrl = ctrl();

Backticks ( `` ) return the output of the command you're executing through the shell, whereas system returns the exit status of the command.


Dave