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


In reply to Shell expansion with &lt;&gt; is funky by tommyboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.