Paul Kraus wrote:
> No your not missing anything I am :) I have never seen this before.
> 
> Looking at the perl book it says that it will subtract a$ from the
> highest multiple of b$ that is not greater then a$.
> 
> So writing a quick loop that does 6 % $i where $i is 1..24 I get
> these results. Which makes sense. But then how could I use this
> operator to test for 456 , 10 11 12 ect. 

You have the operation backwards.

Try:

$ perl -le 'print $_, " -> ", ($_ - 1) % 6 > 2 for 1..24'
2 ->
3 ->
4 -> 1
5 -> 1
6 -> 1
7 ->
8 ->
9 ->
10 -> 1
11 -> 1
12 -> 1
13 ->
14 ->
15 ->
16 -> 1
17 -> 1
18 -> 1
19 ->
20 ->
21 ->
22 -> 1
23 -> 1
24 -> 1

> 
> Even this test produces a 0 on six. Maybe I am missing something but I
> don't see how this would work then again I have never seen this
> before. Thanks for your patients.
> 
> Paul
> 
> 1 0
> 2 0
> 3 0
> 4 2
> 5 1
> 6 0
> 7 .. Infinity = 6.
> 
> 
> 
> -----Original Message-----
> From: Wagner, David --- Senior Programmer Analyst --- WGO
> [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 08, 2003 10:52 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: Looping with multiples?
> 
> 
> Paul Kraus wrote:
> > I have a variable amount of text files that need to get parsed. The
> > files come in groups of 6. I only need to parse files 4 5 and 6. So
> > if 
> 
> > I had 3 groups waiting to be processed then I would have to read
> > through and parse 4,5,6,10,11,12,16,17,18.
> > 
> > The file names look like this...
> > 
> > 6.1.200_(1)_(9443).txt
> > Date_element of group_time.txt
> > 
> > So I would processing all of the files for 6.1.
> > Also I couldn't figure out a way to sort them easily as you will see
> > me in my code so any suggestions there would be helpful also.
> > 
> > How can I setup a loop that will run the correct amount of times and
> > only parse these files from the group. Here is my code.
> > 
> > 
> > #!/usr/bin/perl
> > 
> > use warnings;
> > use strict;
> > use DBI;
> > 
> > opendir ( DH, "." ) or die ( "Could not open $!\n" ); my @allfiles
> > = readdir(DH); my %sales;
> > foreach ( @allfiles ) {
> >   next unless /^\d+\.\d+\.\d+_/;
> >   push (@{$sales{$1}}, $_) if /^(\d+\.\d+\.\d+)_/;
> > }
> > 
> > foreach (sort keys %sales){
> >   my $salesjournals = scalar(@{$sales{$_}});
> >   &processdate($sales{$_}, $salesjournals);
> >   die;
> > }
> > 
> > sub processdate {
> >   my ($filenames, $salesjournals) = ( shift, shift );
> >   my (%pel, %cfb, %leimkuehler, @files);
> >   foreach ( @ { $filenames } ){
> >     push (@files, $1 . "-$_") if /_\((\d+)\)_/;
> >   }
> >   @files = sort {$a <=> $b} @files;
> >   foreach (@files){
> >     my $tmp = $1 if s/^(\d+)-//;
> >     if ( $tmp == ){
> >       print "$tmp \t $_\n";
> >     }
> >   }
> > }
> 
>       If you are only after the files which are defined by _(n)_ and
> you only want the 4,5 and 6 th elements, then you should be able to
> do a modulus 6 (ie, n % 6) and where 4,5,6 then process otherwise
> bypass.  If I am missing the obvious, sorry, but if going in a
> numeric sequence, the modulo should do it for you.
> 
> Wags ;)
> 
> 
> **********************************************************
> This message contains information that is confidential
> and proprietary to FedEx Freight or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
> ****************************************************************
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to