You might want to post more code if this isn't what you're asking, but you
could try something like this:
@files = ('file1','file2');
foreach $file(@files){
open(INFILE,$file);
while(<INFILE>){
if($_ =~ /^AR/){
$arTotal++;
}elsif($_ =~ /^ACCT/){
$accTotal++;
}
}
close INFILE;
}
print "I found AR $arTotal times, and ACCT $accTotal times.\n";
By the way, I think that when you want to assign the value of an increment,
you should do it like this: $total = ++$count;, otherwise I think you pass
the current value and then increment the variable.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 1:14 PM
To: Perl Beg
Subject: Looping Code ?
What I am trying to do is get a total of line that
matches a specific criteria and when it stops matching
return the total to variable. If I have the following
files:
file1: file2:
$line[1] = $field[0]
AR AR
AR ACCT
AR
ACCT
ACCT
ACCT
ACCT
and use the following:
if ($line[1] = (/^:$field[0]/)) {
$total = $count++;}
I want $total for AR to = 3 and $total for ACCT = 4.
When I run it I get
1
2
3
3
3
3
3
1
2
3
4
4
4
4
4
4 etc...
Any thoughts
Thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------------------
This email may contain confidential and privileged
material for the sole use of the intended recipient.
If you are not the intended recipient, please contact
the sender and delete all copies.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]