Stupid Mac::Glue Tricks

pudge on 2003-11-19T23:12:24

I find one-liners in Mac::Glue to be annoying.

perl -MMac::Glue=:all -le '$itunes = new Mac::Glue "iTunes"; print $itunes->prop("player state")->get'

It's a mouthful, and mostly boilerplate. So how about this little shell script? Standardize on one glue var name, $g, and suck in Data::Dumper, which I commonly use, and:

#!/bin/sh perl -MMac::Glue=:all -MData::Dumper -l -e 'splice(@ARGV, 1, 1); $g = new Mac::Glue shift;$g->ERRORS(1);' -e "$2" "$@"

Now I can do:

glue iTunes 'print $g->prop("player state")->get'