in reply to Re: Indexing Files with Plucene::Simple
in thread Indexing Files with Plucene::Simple
2.Aighearach'smap { $_ => do { local ($/,*F); open F, "<$_" or die "Error reading '$_': $!"; <F> }} glob('*') #or map{$_=>do{open my $fh,$_ or die"$_:$!";<$fh>}}glob('*')
3.atcroft'spackage MyPackage; sub make_hash { (local $/)=undef; my (@files,%hash); @files = @_; foreach my $file ( @files ) { open( my $fh, $file ) or next; $hash{$file} = <$file>; }; return \%hash; } __END__
foreach $filename (glob('*', '.*')) { open(DF, $filename) or die(); @{$hash{$filename}} = <DF>; close(DF); } #the snippet i mentioned would have had the contents in @{$hash{$fi +lename}}, #but you would have had to reassemble that back into a single strin +g, if that is what you needed)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Indexing Files with Plucene::Simple
by perrin (Chancellor) on Nov 04, 2004 at 15:19 UTC |