I am trying to parse a single file in a series of directories that is frequently updated and and renamed
with a postfix according to the date.
I do this by iterating through the directories and matching the files I want to parse with forced shell expansion inside calls to open open(FH,<*fpc>).
It works the first time through and then fails.
The <> returns undef but the files I am trying to parse do in fact exist.
Does <> shell expansion only get compiled once -- is there a way to force it to evaluate every time.
There are other ways to solve this problem but <> is the simplest/most elegant, if it only worked.
#!/usr/bin/perl -w
use strict;
#directory containing fpc map dirs
my $fpcdir = '/home3/ftp/pub/gsc1/fpc_files';
#organism/fpc map dir names
my @projects = ("mouse","human","cb","arab");
my %stats;
#foreach of the fpc maps get total clones and contigs
foreach(@projects)
{
&get_clones_and_contigs($fpcdir,$_);
}
sub get_clones_and_contigs($$)
{
my ($fpcdir,$project) = @_;
# this is what I can not figure out -
#this works on the first iteration
# but fails to expand correctly the second time
#&get_lones_and_contigs is called.
open(FH,<$fpcdir/$project/*fpc>) || die "$! \n";
while(<FH>)
{
if ($_ =~ /\sContigs\s.(\d+)\s.Clones\s.(\d+)\s/)
{
print "$project: contigs[$1] clones[$2] \n";
my @stats = ($1,$2);
$stats{'project'} = \@stats;
return;
}
}
close FH;
}
below is one of an excerpt of one of the fpc files that needs parsing.
// fpc project master_Humanmap
// 4.6.9 Date: 14:04 Wed 05 Dec 2001 User: scanner
// Contigs 726 Clones 407155 Markers 69507 Bands 12849811
// Framework Chr_Z Genome 0 AvgBand 4000 AvgInsert 174000
// Configure 173 Tol 7 Cut 3e-09 Apx 0.100 Min 3 End 15 Kill -1 Bad 15
+ Best 10 Log 0 Std 1
// CpM Off 50 1 0 TBL 1 1e-05 2 1e-04 3 1e-03
// Build 1/1/70 0:0 Cut 3e-12 Off 50 1 0 TBL 1 1e-08 21e-07 3 1e-06
// Clip(0 4600) MinMax(0 32767) AutoRemark
Edit Masem 2002-01-24 - Fixed title, code tage on file format