About Me

My photo
Working as Technical Lead in CollabNET software private limited.
Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Wednesday, 14 July 2010

Soap calls using perl

This seems to be the quick way for testing soap api's.

#!/usr/bin/perl

#use SOAP::Lite +trace => debug;
use TeamForge;
use Data::Dumper;

my($tf,$sk);

$tf = new TeamForge;
$tf->proxy('http://cu021.cubit.maa.collab.net');
$sk = $tf->loginAnonymous("guestuser");

die "Login failed" unless ($sk);

print Dumper($tf->getProjectData($sk,'proj1007'));

Thursday, 25 September 2008

PERL script for extracting log file based on time

Below code extracts the huge log file based on time frame passed.


#!/usr/bin/perl

use strict;

my $file;
my $times = 0;
my $needed_response_time = 0;
my $start;
my $end;

sub Usage
{
my ($msg) = $_[0];
if ($msg)
{
print STDERR "$msg \n";
}
print STDERR << "EOHELP"
Usage: split_access_log_by_time

options:

-t - :: time interval for which the log is needed
-g

PERL script to combine two csv files

Below script is used to combine two csv files based on the first column. For example, it is assumed both the file has first column related to project names.



#!/usr/bin/perl -w

$FILE1 = $ARGV[0];
$FILE2 = $ARGV[1];
$PROJECTFILE = $ARGV[2];

my %File1Map = ();
my %File2Map = ();

open(FILE1) or die("Could not open $FILE1 file.");
foreach $line () {
# ($Project,$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm) = split(',',$line);
($Project,$values) = split(',',$line,2);
# my $tempval="$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm";
my $tempval = $values;
# print "$Project,$values";
$tempval =~ s/\r|\n//g;
$File1Map{"$Project"} = "$tempval";
}

close(FILE1);

open(FILE2) or die("Could not open $FILE2 file.");
foreach $subline() {
($proj,$izcount) = split(',',$subline);
$File2Map{"$proj"}="$izcount";
}

close(FILE2);

open(PROJECTFILE) or die("Could not open $PROJECTFILE file.");
foreach $projname() {
($name,$dummy)=split('\n',$projname);
my $existingValue=$File1Map{"$name"};
my $newValue=$File2Map{"$name"};

if (! defined $existingValue)
{
$existingValue = ",,,,,,,,";
}
if (! defined $newValue)
{
$newValue = "\n";
}

print "" . $name . "," . $existingValue . "," . $newValue;
}