Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Tuesday, March 11, 2008

perl script to block comment in perl scripts (including itself :P )

yow!

commentscript
a script to comment/uncomment blocks in perl scripts

save this executable perl script in any folder that is included in PATH, or in ~/bin (which is already there in PATH). (and also make sure it is executable if it somehow doesnt work)

Usage: commentscript perlscriptname
where perlscriptname is the... make a wild guess... yip, the script containing the block that you want commented.

Description:
In any perl script, to comment blocks of code, put a block (a collection of consecutive lines, nothing more) between ## and ## (they should both be at the start of a line), and run this script on it (by passing perlscriptname as a command-line argument).

To uncomment, change both the ##'s to ##! and run this script on perlscriptname again.

Example:

print "hi. ";
##
print "hah.";

print " blah hash";
##
print "hash functions are cool";

changes to

print "hi. ";
##
# print "hah.";
#
# print " blah hash";
##
print "hash functions are cool";

and

print "hi. ";
##!
# print "hah.";
#
# print " blah hash";
##!
print "hash functions are cool";

changes to

print "hi. ";

print "hah.";

print " blah hash";

print "hash functions are cool";

ps - for extra safety, the script also makes a backup copy of the original perlscriptname by the name of perlscriptname.backup in the folder that the script (commentscript) is run from.
psst - comments, bug reports, and additional feature requests are... as ever... most welcome.

Monday, March 10, 2008

killprog - handy bash script to kill hung up processes

a handy bash script to kill required processes:

killprog

save this file in your ~/bin/ folder

usage: killprog [program1] [program2] ...

examples:
killprog vlc
killprog firefox
killprog vlc firefox

ps - if it doesnt work, make sure it is an executable.
chmod +x killprog

comments, bug reports, and additional feature requests are welcome :P