in reply to Reading through a file and checking for a specific string
Scanning through your codes, there are several stuff, that is wrong.
Please,
to start with, then you will discovery that several of your codes didn't end with a ;.use warnings; use strict;
You said you are using a glob function, but their is non in your code, so you only have the string "/export/home/date_file*.txt", in your array variable "@files".
Update:
I have array1 - @types that has these 2 letter strings(which I am supposed to check for in each file in each line, This variable is found in each line at 41st character.) and array2 - @counts where I am trying to store count if that match is found.Instead of using two arrays, why don't you use a HASH, with the type of strings you would be looking for as the keys and initialized them to zero like so:
my %type; @type{qw(AB AC AD AE FG)} = (0) x 5;
then later you can do... *##then you have something like this: $VAR1 = { 'AC' => 0, 'AE' => 0, 'FG' => 0, 'AB' => 0, 'AD' => 0 };
*NOTE:while(...){ ... $type{$_}++; ## increasing the counting as you see needed string ... }
I don't except the pseudo-code to work, since the OP didn't show any dataset.
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Reading through a file and checking for a specific string
by vihar (Acolyte) on Aug 19, 2013 at 20:20 UTC | |
by 2teez (Vicar) on Aug 19, 2013 at 21:52 UTC |
In Section
Seekers of Perl Wisdom