I fixed it.
#!/usr/bin/perl
#use warnings;
#use diagnostics;
my $count = 0;
@client = qw(apples oranges pears kiwi);
$Input_File="crapdata1.txt";
open(INP, $Input_File);
@by_jobname=<INP>;
close(INP);
foreach $Client_Key (@client)
{
foreach $New_Jobname (@by_jobname)
{
$em_job = substr($New_Jobname,11,50);
$em_key = substr($New_Jobname,11,2);
if ($em_key eq $Client_Key)
{
$count = $count + 1;
}
}
print "$Client_Key count is: $count\n";
$count = 0;
}
exit;
From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]
On Behalf Of Kevin Patterson
Sent: Wednesday, June 17, 2009 1:18 PM
To: perl-beginner@yahoogroups.com
Subject: RE: [PBML] Newbie question
Sorry...
Here is what I wrote:
#!/usr/bin/perl
#use warnings;
#use diagnostics;
my $count = 0;
my $key_count = 0;
$Input_File="crapdata1.txt";
open(INP, $Input_File);
@by_jobname=<INP>;
close(INP);
foreach $New_Jobname (@by_jobname)
{
$em_job = substr($New_Jobname,11,50);
$em_key = substr($New_Jobname,11,2);
if ($em_key eq "Apples")
{
$count[1] = $count[1] + 1;
}
}
print "$em_key count is: $count[1]\n";
my $count = 0;
foreach $New_Jobname (@by_jobname)
{
$em_job = substr($New_Jobname,11,50);
$em_key = substr($New_Jobname,11,2);
if ($em_key eq "Oranges")
{
$count[2] = $count[2] + 1;
}
}
print "$em_key count is: $count[2]\n";
exit;
It give me the following results:
Apple Count is: 2
Oranges Count is: 1
Here is the data.
Apples |Sweet
Oranges |Seeds
Apples |Sour
-----Original Message-----
From: perl-beginner@yahoogroups.com <mailto:perl-beginner%40yahoogroups.com>
[mailto:perl-beginner@yahoogroups.com
<mailto:perl-beginner%40yahoogroups.com> ]
On Behalf Of Scot Robnett
Sent: Wednesday, June 17, 2009 12:22 PM
To: perl-beginner@yahoogroups.com <mailto:perl-beginner%40yahoogroups.com>
Subject: RE: [PBML] Newbie question
What is the exact format of the file?
What have you tried so far?
Nobody is going to write the script for you. The group is here to help
you figure things out when you get stuck or something isn't working, but
you're supposed to try something first.
-----Original Message-----
From: perl-beginner@yahoogroups.com <mailto:perl-beginner%40yahoogroups.com>
[mailto:perl-beginner@yahoogroups.com
<mailto:perl-beginner%40yahoogroups.com> ] On Behalf Of Kevin Patterson
Sent: Wednesday, June 17, 2009 2:11 PM
To: perl-beginner@yahoogroups.com <mailto:perl-beginner%40yahoogroups.com>
Subject: [PBML] Newbie question
Hello..
I am writing a perl program in windows..
Here is my problem.
I have a file containing data such as:
Apples
Oranges
Pears
Bananas
Plums
Apples
Oranges
Pears
bananas
kiwi
Apples
Oranges
Pears
bananas
I write a program to read this file and create a summary report showing
How many apples:
How many oranges
How many Pears
Can anyone help me??
thanks
[Non-text portions of this message have been removed]
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.374 / Virus Database: 270.12.73/2180 - Release Date:
06/17/09 05:53:00
No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.374 / Virus Database: 270.12.73/2180 - Release Date:
06/17/09 05:53:00
[Non-text portions of this message have been removed]
------------------------------------
Unsubscribing info is here:
http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
[Non-text portions of this message have been removed]