Perl Joke
Just a joke - no offense intended…
perl -e '$a="etbjxntqrdke";$a=~s/(.)/chr(ord($1)+1)/eg;print $a'
Just a joke - no offense intended…
perl -e '$a="etbjxntqrdke";$a=~s/(.)/chr(ord($1)+1)/eg;print $a'
If you are getting a ‘Can’t locate CPAN.pm in @INC’ error while opening cpan, you have not installed Bundle::Cpan. You can do that without Cpan - using yum
yum install perl-CPAN
Remove comments and blank lines from example.pl
sed '/ *#/d; /^$/d' example.pl
A perl script to stop crond if mysqld is down
#!/usr/bin/perl
# See if MySQL server is alive or not
$mysql_status = `/etc/init.d/mysqld status`;
print "MySQL Status: $mysql_status\n";
unless($mysql_status =~ /running/) {
print "Stopping Cron... ";
#If MySQL is not running, kill the crond
$cron = `/etc/init.d/crond stop`;
print $cron;
}
print "\n";
[tags][/tags]
Show the headers of an URL from the command line. This will need perl, lwp installed on the system.
lwp-request -ed "http:/lindesk.com/"
Print a file until a regular expression is matched.
cat file.txt | perl -pe "exit if(/Thats all/)"
Remove all empty directories within the current directory
find . -type d -empty -exec rmdir {} \;
perl -MFile::Find -e"finddepth(sub{rmdir},'.')"
Delete Empty Directories
http://www.jonasjohn.de/lab/red.htm
[tags]empty,folder,delete,remove,perl,command,linux[/tags]
The command to convert all \n in a file to another string - very useful for list code generation.
perl -ne 's/\\n/\',\'/g;print;' file.txt>new.txt
This command will list all the files a folder without their extensions. Comes handy when doing shell scripting
perl -e 'while(<*.*>){s/\..{3}$//i;print "File \"$_\"\n";}print "\n";'
This script will package your SVN code to a tar.gz file. Just give the name of the project as the first argument. Like this…
perl packager.pl jus5
#!/usr/bin/perl
#Package a Sourceforge project from its SVN source.
die("Please provide the name of the project as the argument") unless($ARGV[0]);
$project=$ARGV[0];
#$project='jus5';
`svn checkout https://$project.svn.sourceforge.net/svnroot/$project`;
`find $project/ -name .svn -exec rm -rf {} \\;`;
`tar -czf $project.tar.gz $project/`;
`rm -rf $project/`;
[tags]source,sourceforge,project,package,perl,script,svn[/tags]