#!/usr/bin/perl # This script reads a file and creates 2 variables with it by using a hash. # the data is in 2 columns. Column1=msisdn Column2=DeletionDate # This script may be helpful if expanded to a loop and db query for figuring # last possible active date. # # Sample of the file read by script # 19992507638 deletions.20060723 # 19993017551 deletions.20060723 use strict; use warnings; use DBI; my $database = "chai"; my $hostname = "localhost"; my $port = "3306"; my $username = "bonezer"; my $password = 'monezer'; my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; my $dbh = DBI->connect($dsn, $username, $password) or die("Could not connect!"); my $sql = "select to_days(substring( ?,11)) - to_days(lastactive) from user where number = ? into OUTFILE '/tmp/sp'"; my $sth = $dbh->prepare($sql); open(DATA, "/tmp/SEOUL_NUMBERS") or die "Failed to open /tmp/SEUL_NUMBERS file: $!"; my %hash; while( ) { @elements = split / /, $_; $hash{ $elements[0] } = $elements[1]; $hash{ $elements[1] } = $elements[1]; $sth->execute($elements[1], "$elements[0]\n"); } $dbh->disconnect;