in reply to Re: Search and store solution?
in thread Search and store solution?
I am trying my self imposed assignement in chunks. Can someone help me figure out why it is not working? Thanks.#!/usr/bin/perl -w use strict; #declare vars my $dir_to_process; #sclar to hold directory location my $file; #sclar to hold file names my %stuff_to_store; #hash of directory locations and file names $dir_to_process = "." ; #defining starting directory location opendir DH,$dir_to_process or die "Cannot open $dir_to_process for pro +cessing: $!"; #opening dir to process foreach $file (readdir DH) { #cycling through the directory if ($file =~ /\.txt$/) { #looking for file ext .txt open(my $fh, $file) or die "Unable to open '$file' for reading +: $!"; #reading .txt files while (<$fh>) { #cycling through to find happy if (/happy/) { #if its happy then store it in hash stuff_t +o_store with file location %stuff_to_store = ($dir_to_process, $file); while (%stuff_to_store) { #see if it worked and print +out each element of hash stuff_to_store print; #its not working and I don't know why } } } close ($fh); } } closedir DH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Search and store solution?
by Limbic~Region (Chancellor) on Jul 12, 2008 at 20:31 UTC | |
|
Re^3: Search and store solution?
by YYCseismic (Beadle) on Jul 14, 2008 at 17:40 UTC | |
|
Re^3: Search and store solution?
by Anonymous Monk on Jul 11, 2008 at 16:15 UTC |