activeperl@listserv.ActiveState.com
[Top] [All Lists]

Re: More time calculations

Subject: Re: More time calculations
From:
Date: Wed, 9 Mar 2005 12:40:26 -0600
2 things: this:
     if ($title =~ m/@zoo/       ) # here I don't know what to insert

won't really work - you could do:
my $zoo = join("|",@zoo);
if ( $title =~ /$zoo/ ) {

however, an empty entry (i.e. push(@zoo, ""); ) will make it always match. 


Try a hash:
my $verbose = 0;
my (%zoo, @row);
# init 'family' entry
$zoo{family}++
while ( @row = $cursor_title->fetchrow_array) {
     my $title                 = $row[0];
     if ( $zoo{$title}     ) {  # title already seen
# just for something to do
            print STDERR "Title $title already seen\n"
               if $verbose;
     } else {
            print "$title";
     }

     $zoo{$title}++;
}

Or, more perlish:
...
while ( @row = $cursor_title->fetchrow_array) {
   my $title = $row[0];
   print STDERR "Got Title $title\n"
               if $verbose;
   print "$title" 
      unless $zoo{$title}++
}

a

Andy Bach, Sys. Mangler
Internet: andy_bach@xxxxxxxxxxxxxxxxx 
VOICE: (608) 261-5738  FAX 264-5932

In 1968 it took the computing-Power of 2 C-64 to fly a rocket to the moon.
Now, 1997 it takes the Power of a Pentium 133 to run Microsoft Windows 95.
                    Something must have gone wrong.
_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

<Prev in Thread] Current Thread [Next in Thread>