#!/usr/bin/perl # # ifZero.pl - wraps selection in #if 0/#endif # # I keep this script just after "Un/Comment" in the Comments subfolder. # # by Nate Weaver (Wevah) # v 1.0, August 14, 2006 # http://www.derailer.org/ # # -- PB User Script Info -- # %%%{PBXName=#if 0 Selection}%%% # %%%{PBXInput=Selection}%%% # %%%{PBXOutput=ReplaceSelection}%%% # %%%{PBXKeyEquivalent=@\\}%%% # my @selection = ; # read the selection from standard input $" = ''; # concat the array as-is, with no extra chars exit if (!@selection); # no chars in selection, nothing to do if ($selection[0] =~ m/^#if 0/) { print "%%%{PBXSelection}%%%"; print "@selection[1 .. $#selection - 1]"; print "%%%{PBXSelection}%%%"; } else { print "%%%{PBXSelection}%%%"; print "#if 0\n"; print "@selection"; print "\n" if $selection[$#selection] !~ m/\n$/; print "#endif\n"; print "%%%{PBXSelection}%%%"; }