PerlTemplate: Difference between revisions

From RAJ INFO
Jump to navigation Jump to search
m New page: <pre> #! /usr/bin/perl -w # ************************************************************* # This Programme does the following in sequence # -> # -> # Author: Rajkumar (itc@rajkumar.in) #...
 
mNo edit summary
Line 1: Line 1:
<pre>
<perl>
#! /usr/bin/perl -w
#! /usr/bin/perl -w
# *************************************************************
# *************************************************************
Line 69: Line 69:
# END
# END


</pre>
</perl>

Revision as of 03:37, 23 August 2008

<perl>

  1. ! /usr/bin/perl -w
  2. *************************************************************
  3. This Programme does the following in sequence
  4. ->
  5. ->
  6. Author: Rajkumar (itc@rajkumar.in)
  1. *************************************************************
  1. Libraries

use strict; use DBI;

  1. At the top: Time Start

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

  1. Variables

my $path = ""; my @file = @_;

  1. Connecting to the database

my $dbh = DBI->connect('DBI:mysql:database:host', 'usr', 'pwd') or die $!;

  1. Reading a file line by line
       foreach my $line (split ("\n", `cat $path/file`))

{

       }
  1. Open a dir

opendir (DIR, "$path") or die $!; @files = readdir(DIR); close(DIR);

foreach my $file(@files) { next if ($file eq "." or $file eq "..");

print $file."\n"; }

  1. Parse CSV

open(CSV_FILE, "parse_me.csv") or die "unable to open file 'CSV_FILE': $!\n"; <CSV_FILE>; # skip header line while (<CSV_FILE>){ ($column1, $column2, $column3, $column4) = split(/\t+/, $_); }

  1. Open a file

open (GFF, ">>".$file.".gff"); print GFF $gffout; close GFF;


  1. At the End: Time Calculation

my ($sec_,$min_,$hour_,$mday_,$mon_,$year_,$wday_,$yday_,$isdst_) = localtime(time); my $days = $mday_-$mday; my $hours = $hour_-$hour; my $mins = $min_-$min; my $secs = $sec_-$sec; print "\n------------------------\nDuration: "; if ($days>0) { print "$days days";} if ($hours>0) { print ": $hours hours";} if ($mins>0) { print ": $mins mins";} if ($secs>0) { print ": $secs secs";} print "\n------------------------\n";

  1. END

</perl>