• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Posts tagged Perl

Web Dev> Obtaining Google PageRank

Jun06
2012
Written by Scott Rowley

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 »

Posted in MySQL, PHP, SEO, Web Development - Tagged database, google, MySQL, page, page rank, php, prchecker.info, rank, script, search engine optimizaiton, SEO

Linux> Aliases

Jun08
2011
Written by Scott Rowley

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 »

Posted in BASH, Ubuntu - Tagged alias, basic, conditional, epoch, ggrep, grep, if, include, linux, print, profile, reload, solaris, time, ubuntu, unix, whois

Perl> Useful one-liners

Dec08
2010
Written by Scott Rowley

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
Tagged delimiter, insert, liner, one, one-liner, remove, replace, string, variable

BASH> How to install perl modules through CPAN on Ubuntu

Oct26
2010
Written by Scott Rowley

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
Posted in BASH - Tagged BASH, cpan, install, module

Perl> Get IP only from logfiles

Oct26
2010
Written by Scott Rowley

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;
Tagged BASH, IP, log, logfile, print

Web Dev> CGI-based redirect

Oct26
2010
Written by Scott Rowley

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";
Posted in Web Development - Tagged cgi, code, Web Development

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top