Perl Joke
Tagged with: command, humor, joke, Linux, Perl
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
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]
This one command will fetch and display the latest sensex figure in Linux. This command basically downloads a page, locates a specific line, and then extract just the necessary portion from it. I am sure you could find other uses for this method.
curl -s "http://money.rediff.com/money/jsp/markets_home.jsp" |grep ''|head -n1|perl -pe 's/^.+\">([\d\,\.]+)<\/TD>.+$/\1/i;'
No Comments »
Command to Print Until Regular Expression
Tagged with: command, expression, match, Perl, regular, string
Monday, October 1st, 2007 11:43 PM
Print a file until a regular expression is matched.
cat file.txt | perl -pe "exit if(/Thats all/)"
No Comments »
Remove empty directories
Tagged with: command, delete, empty, folder, Linux, Perl, remove
Thursday, September 13th, 2007 12:07 AM
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]
No Comments »
Replace \n with another String
Tagged with: command, line, Perl, replace, string
Friday, June 29th, 2007 06:25 PM
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
No Comments »
Remove Extension in Shell Scripting
Tagged with: command, extension, file, folder, Linux, list, Perl, script
Wednesday, June 27th, 2007 08:28 PM
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";'
No Comments »
SourceForge Project Packager - from SVN source
Tagged with: package, Perl, project, script, source, sourceforge, svn
Saturday, May 5th, 2007 09:05 PM
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]
No Comments »
Installing Perl Modules
Tagged with: cpan, install, module, modules, Perl
Sunday, April 22nd, 2007 11:10 PM
Install Perl modules on a linux system - must be connected to the net
perl -MCPAN -e shell
If CPAN is not installed use this command to install it in a RedHat/Fedora system.
yum install perl-CPAN
If you are doing this for the first time, there will be a configuration procedure.
install XML::Parser
Some recommended Modules
DBI
DBD::mysql
MIME::Lite
MIME::Words
Compress::Zlib
MIME::Base64
URI::URL
HTML::Tagset
HTML::Parser
LWP::Simple
GD
RPC::XML
SOAP::Lite
XML::RSS
No Comments »