You can use Tie::Toggle under the same terms as Perl itself.