Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Reading through a file and checking for a specific string

by 2teez (Priest)
on Aug 19, 2013 at 21:52 UTC ( #1050093=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Reading through a file and checking for a specific string
in thread Reading through a file and checking for a specific string

Yes, you have, but there are still some there.
You still have a single quote without it's corresponding part here

@files = glob ('/export/home/date_file*); ^ ^<-- not there
Then instead of these
 $counts[$i] ...
$files[$i]..
$counts[$i]++..
you are writing  @counts[$i] ...
@files[$i]..
@counts[$i]++.. Which in this case is not correct.

If I may give you a head up ( it might not be the best suited for you but it might point you in a right direction ).
I have a few text file in a directory, and am reading each file to see how many times some certain words were used like this:
use warnings; use strict; use Data::Dumper; my %type; @type{qw(is a an at)} = (0) x 4; for my $file ( glob "*.txt" ) { open my $fh, '<', $file or die $!; while (<$fh>) { for (split) { $type{$_}++ if exists $type{$_}; } } } print Dumper \%type; my $total = 0; $total += $type{$_} for keys %type; print $total, $/;

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


Comment on Re^3: Reading through a file and checking for a specific string
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050093]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2014-12-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (74 votes), past polls