[26149] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8340 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 20 00:05:29 2005

Date: Fri, 19 Aug 2005 21:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 19 Aug 2005     Volume: 10 Number: 8340

Today's topics:
    Re: how to read file from sub-directories and do an ave xhoster@gmail.com
        Perl module error at runtime <tjgatlga@bellsouth.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 19 Aug 2005 22:24:10 GMT
From: xhoster@gmail.com
Subject: Re: how to read file from sub-directories and do an average?
Message-Id: <20050819182410.622$4X@newsreader.com>

"Ross" <a@cuhk.edu.hk> wrote:
> I have the following directories under a dir called raw data-1, and under
> each subdir, say, 4601-4.SMP, there is a single file under there. indeed
> that single file has a fixed format and i'm going to extract numerical
> values there to write to a new file along with two from 4601-4B.SMP and
> 4601-4C.SMP. Since a user does not follow nomenclature strictly,
> sometimes he names a dir, say, 4601-4A.SMP instead of 4601-4.SMP, how
> could i achieve extracting 3 files and write to a single file?

IMHO, you can't.  Either a user does what he is supposed to, or he doesn't.
If the user doesn't, then all you can do is guess.  What if your user
decides to not follow nomenclature stricly by sticking the A before the 2nd
number segment rather than after it?  What if he fails to follow
nomenclature strictly by mis-spelling 4601-4A.SMP as 4603-4A.SMP?  Either
it is allowed to add a letter after the 2nd number segment, in which case
the user *is* following nomenclature strictly, or we are just playing a
guessing game.

Anyway, I've handled similar situations something like:

my %set;
##Find the set of all groups to be averaged over
my @files=glob "*SMP";
foreach (@files) {
  /^(\d+-\d+)/ or die "invalid format $_";
  $set{$_}=();
};

foreach my $group (keys %set) {
  foreach my $member ( fgrep /^\Q$group\E\D/ , @files) {
    ##open $member and do whatever you do
  };
  ## do whatever output you need for the group
};

The \D in the regex makes sure that 4594-32.SMP is not considered part
of the group "4594-3".  (And the ^ makes sure that 594-3.SMP isn't
considered part of the group 4594-3)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 19 Aug 2005 21:59:01 -0400
From: "John Smith" <tjgatlga@bellsouth.net>
Subject: Perl module error at runtime
Message-Id: <06wNe.37760$rp.27244@bignews1.bellsouth.net>

I installed a perl module I got from a books' CD copy of CPAN.  We are 
currently running 5.8.6.

From the book, I copies this script and tried to run it.

The script

use Date::Calc qw(Days_in_Month Month_to_text today);

my ($year, $month, $day) = Today();
my $days_in_Month = Days_in_Month($year, $month);
my $month_text = Month_to_text($month);

print "There are $days_in_Month days in the month of $month_text\n";


Generates this error message:

Can't load module Date::Calc, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the Date::Calc module statically linked into it.)
 at datecalc1.pl line 3
Compilation failed in require at datecalc1.pl line 3.
BEGIN failed--compilation aborted at datecalc1.pl line 3.


When I installed the module, the "make" did not generate any kind of errors.

Anybody have an idea what I'm missing here? 




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8340
***************************************


home help back first fref pref prev next nref lref last post