Upgrade Perl modules using cpan autobundle


It’s become bi weekly task to keep updated your Perl distro.

To achieve it I use following commands

perl -MCPAN -e shell
cpan> autobundle

Above command will generate a snapshot pm file. This file will include list of modules require upgrade.

Example
Snapshot_2012_05_01_01.pm

You can recheck the file and list of module with respective version. You have a facility to remove any of unwanted packages to your distro.

Once done the modification of the file you save it.

Now run below command

cpan> install Bundle::Snapshot_2012_05_01_01

This command will take care of installation of all these module incorporated in Snapshot_2012_05_01_00 file.

Bingo thats all! WeW

Perl GMAIL Feed


#!/usr/bin/env perl
use warnings;
use strict;

=head1 INTRODUCTION

Checks if there are new unread messages in your GMail Inbox.

=head1 USAGE

$ perl check_gmail.pl
=cut

############## Configuration ##############

# Change this to your correct username.
use constant GMAIL_USERNAME => “username”;
# Change this to your correct password.
use constant GMAIL_PASSWORD => “password”;

########## Don’t change anything below this. ##########

use LWP::UserAgent;
use XML::Atom::Feed;

my $fetcher = LWP::UserAgent->new();
$fetcher->agent(“check_gmail.pl/0.01″);

my $request = HTTP::Request->new(
‘GET’   => “https://mail.google.com/gmail/feed/atom”,
);
$request->authorization_basic(GMAIL_USERNAME, GMAIL_PASSWORD);

my $response = $fetcher->request($request);

if (! $response->is_success())
{
die(“Unsuccessful in trying to talk to GMail”);
}

my $content = $response->content;
my $feed = XML::Atom::Feed->new(\$content);
my @new_messages = $feed->entries();

my $i = 1;
foreach my $message(@new_messages)
{
print join(“\t”, $i, $message->author->name,
$message->title), “\n”;
$i++;
}

# The End

MYSQL replication in the same box


MYSQL replication in the same box

 

MYSQL 5.0.17 standard (SLAVE) – 10.0.0.1

MYSQL 4.1.1 standard (MASTER) – 10.0.0.2 MASTER running on port 3306 SLAVE running on port 3308 MASTER (my.cnf)
server-id = 1
log-bin SLAVE (my.cnf)
[mysqld]
server-id = 2
master-host = localhost
master-user = root
master-password = mysql
master-port = 3306

replicate-do-db = dbrep

to check the MASTER status on mysql cosole execute this querymysql > SHOW MASTER STATUS;

mysql > grant replication slave, replication client,file,super,reload,select on *.* to root@’%hostname%’ identified by ‘mysql’; to check the SLAVE status on mysql cosole execute this querymysql > SHOW SLAVE STATUS;

mysql > grant all on *.* to root@%hostname% identified by ‘mysql’; mysql> CHANGE MASTER TO
-> MASTER_HOST=’master_host_name’,
-> MASTER_USER=’master_user_name’,

-> MASTER_PASSWORD=’master_pass’,

-> MASTER_LOG_FILE=’recorded_log_file_name’,

-> MASTER_LOG_POS=recorded_log_position;
Above mentioned query can be used to chnage the slave info at runtime. restart both MYSQL SLAVE & MASTER On slave execute the command
mysql > start slave; Now create the database at MASTER and start creating tables and inserting values into it. Check the slave it started replicating all those tables. Isn’t it simple. )