As a part of Search Engine Optimization (SEO) you may want to be aware of your websites (or clients websites) page rank on Google. After some researching I’ve found the following solutions to be best. I’ll be presenting a few options here, first we’ll cover how to look it up on prchecker.info. Second we’ll be covering how to look up the page rank using a perl script and finally we’ll cover how to look up your page rank with the perl script and update a mysql database with the information (for long term tracking and/or tracking multiple websites.)
READ MORE »
Posts tagged Perl
Web Dev> Obtaining Google PageRank
Linux> Aliases
Aliases can be a great way to more easily remember an oddball command or to shorten a long command. Aliases are stored in your .profile (or .bash_profile) or within a include file referenced from .profile.
A couple of quick examples before showing how to set them up:
READ MORE »
Perl> Useful one-liners
Remove string from file
perl -ni -e 'print unless /pattern/' /path/to/filename
Replace string with string
perl -p -i -e 's/PATTERN/NEW_ENTRY/g' /path/to/filename
Insert string where delimeter is found
This will replace the original delimiter with the new entry and then add the delimiter so you can use it again in the future.
perl -p -i -e 's/DELIMETER/NEW_ENTRY\n\nDELIMETER/g' /path/to/filename
This will grab anything thats in the standard IPv4 format (anything! not always IPs…but usually).
perl -ne 'print "$&\n" while m#\d+\.\d+\.\d+\.\d+#g' file.txt
Search for and find whole paragraphs containing $string
perl -00ne "print if /$string/i" < file.txt
BASH> How to install perl modules through CPAN on Ubuntu
Install all dependent packages for CPAN
sudo apt-get install build-essential
Invoke the cpan command as a normal user
cpan
Once you hit on enter for “cpan” to execute, you be asked of some few questions. To make it simple for yourself, answer “no” for the first question so that the latter ones will be done for you automatically.
Enter the commands below
make install install Bundle::CPAN
Now all is set and you can install any perl module you want. examples of what installed below:
cpan prompt> install IO::File cpan prompt> install Net::SMTP_auth cpan prompt> install Email::MIME::Attachment::Stripper cpan prompt> install Mail::POP3Client
Perl> Get IP only from logfiles
Being an ISP admin, I have regular need to find IP addresses listed in large logfiles. The following will grab anything that appears to be an IP and list it out for you, from there you can sort or whatever you want to do with the list.
perl -ne 'print "$&n" while m#d+.d+.d+.d+#g' <logfile>
Or just throw it in a bash script for easier remembering:
getip.sh
#!/bin/bash perl -ne 'print "$&\n" while m#\d+\.\d+\.\d+\.\d+#g' $1;
Web Dev> CGI-based redirect
Recently I replaced an old .cgi file with a shiny new .php page. I realize everyone is still linking to the old .cgi file so I had need to forward them all onto the sexy new page. This can be accomplished as easily as the following:
Simply replace (after backing up) your .cgi file with the following contents
#!/path/to/perl print "Location: http://domain.com/newpage.php\n\n";