Could you give an actual code example, i'm not sure what you're saying. It appears from the MySQL documentation that the ENCODE function requires 2 parameters, but you haven't mentioned that. Anyway, likely the best way is to just connect to MySQL and perform the operation, for example:
my $dsn = 'DBI:mysql:host=localhost';
my $dbh = DBI->connect($dsn);
my $sth = $dbh->prepare("SELECT DECODE('encodedcontent', 'secretvalue'
my $decoded = $sth->fetchrow;