Perl one-liner for ColdFusion XML configuration file

I wrote a Perl one-liner to modify ColdFusion's adminconfig.xml file to enable the migration wizard using ColdFusion 8 settings. It's somewhat silly, since it's probably every bit as easy to make the change with an editor by hand. However, if you're automating the upgrade of many servers, it could be useful.

ACTION=on for SETTING in runmigrationwizard migratecf8; do perl -p -i -e 'BEGIN{$s=$ENV{"SETTING"}; $a=$ENV{"ACTION"}; %tf=(0,"false",1,"true"); $vs=($a = ~/^on/)?0:1; $vf=($vs eq 0)?1:0; $m="(<$s>)".$tf{$vs}."(</$s>)";} s/$m/\1$tf{$vf}\2/i' adminconfig.xml done

I tried to make it as concise as possible, and there is definitely a shorter way to make the change. However, I wanted to support flipping the values in either direction (on/off). This would conceivable work on any XML file that places simple true/false values in the text node of simple elements. Yes, both of those files! Heh.

PS: I'm posting this on my own blog (which I so rarely do anymore) because I know that Posting all those special characters would have been a complete nightmare on my Posterous blog.