Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by vihar (Acolyte)
on Aug 19, 2013 at 20:20 UTC ( [id://1050084]=note: print w/replies, xml ) Need Help??


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

Hi, I just updated it in my code. There were a few lines I added manually when I was writing this question. I forgot to put semi colons and glob function but I did that now. Thanks
  • Comment on Re^2: Reading through a file and checking for a specific string

Replies are listed 'Best First'.
Re^3: Reading through a file and checking for a specific string
by 2teez (Vicar) on Aug 19, 2013 at 21:52 UTC

    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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found