You should, ah, ace that homework with the kind of help you got on this one :-)



On Wed, 6 Oct 2004 09:06:52 +0800, Bee <[EMAIL PROTECTED]> wrote:
> Try this and hope this would help more.... *Code not tested*
> 
> Suppose data in cancel.txt :
> 123456|X
> 234567|X
> 
> Suppose data in falldata.tmp :
> 028076|Blood|Sept 18|Sat|San Francisco|028086.html|1|275|0||
> 123456|Quake|Sept 19|Sun|Home|028087.html|1|275|0||
> 234567|Doom|Sept 20|Mon|Page Up|028088.html|1|275|0||
> 345678|Neverhood|Sept 21|Tue|Ctrl-C|028089.html|1|275|0||
> 
> #Code
> use strict;
> 
> my @cancel ;
> open C, "cancel.txt" or die "$!";
> while (<C>) {
>    my ( $code, $waste ) = split /\|/, $_ ;
>    push @cancel , $code
> } close C;
> 
> my %course ;
> open F, "falldata.tmp" or die "$!";
> while (<F>)
> { chomp ;
>    my @detail = split /\|/, $_;
>    my $code = shift @detail;
>    $course{$code} = [EMAIL PROTECTED]
> } close F;
> 
> for my $code (keys %course)
> {   $course{$code}[8] = "C"  if  ( grep /$code/, @cancel )  ;
>     my $status = $course{$code}[8] ? "CANCELED" : "OKAY";
>        print "\n\n --- $status -------- \n";
>        print "$_ : $course{$code}[$_] \n"  for (0..8)
> }
> 
> HTH,
> Bee
> 
> 
> 
> 
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 06, 2004 4:32 AM
> Subject: newbie stuck in a HOA
> 
> > Hi all,
> >
> > I have a flatfile database (falldata.tmp) that contains information about
> > all the courses offered
> > this includes: course number, course title, start date, day of week,
> > location, html link, section number, fee1, fee2, and status.
> >
> > I have another file (cancel.txt) which contains a list of the courses that
> > are canceled.
> >
> > What I want to do is change the status to "C" in the flatfile database, if
> > it is in the cancel file.
> >
> > The problem I'm having is that
> > I'm getting duplicate results and also incorrect results as the code isn't
> > distinguishing between a canceled class and one that's not.
> >
> >
> > Any ideas on where I'm going wrong.
> > Thanks in advance,
> > Pam
> >
> >
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to