in reply to Re: Read files not subdirectories
in thread Read files not subdirectories
Could I please ask another question? After using "next unless -f $file" the program runs, but fails to execute anything thereafter. As a test, I inserted a simple PRINT statement immediately after the "next unless" statement, and received nothing. If I uncomment the "next if" statement, and omit the "next unless", then the simple PRINT statement works, but the program crashes trying to execute the write statement. In sum, it seems that the "next unless" filters out all obs. Make any sense?
#! /usr/bin/perl -w use strict; use warnings; use lib "c:/strawberry/perl/site/lib"; use HTML::Strip; my $hs = HTML::Strip->new(); my $write_dir = 'G:\research\sec filings 10k and 10Q\data\filing docs\ +1993\Clean'; my $files_dir = 'C:\Dwimperl\Perl\1993'; opendir (my $dir_handle, $files_dir) || die "failed to open '$files_di +r' <$!>"; while (my $file = readdir($dir_handle) ) { next unless -f $file; #next if $file eq '.' or $file eq '..'; open my $file_handle, "/dwimperl/perl/1993/$file" or die "failed t +o open '$file' <$!>"; while (my $line = <$file>) { my $clean_text = $hs->parse( ' ' ); print $write_dir "$file\n"; $hs->eof; } } close(); closedir $dir_handle;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read files not subdirectories
by parv (Parson) on Jan 30, 2015 at 03:17 UTC | |
|
Re^3: Read files not subdirectories
by wrkrbeee (Scribe) on Jan 30, 2015 at 03:24 UTC | |
by parv (Parson) on Jan 30, 2015 at 03:27 UTC | |
|
Re^3: Read files not subdirectories
by locked_user sundialsvc4 (Abbot) on Jan 30, 2015 at 15:15 UTC |