in reply to need to create blank file in directory
If you want unique values think of hash keys
poj#!perl use strict; my @lines = ( ',,1,,one', ',,0,,zero' , ',,2,,two' ); # parse lines my %uniq = (); foreach (@lines) { my @fields = split /,/; if ( ($fields[2] eq '1') or ($fields[2] eq '0') ) { ++$uniq{$fields[4]}; } } print "$_\n" for sort keys %uniq; # create fh my $dir = '/tmp/loc/'; my %dmphash = (); for (keys %uniq){ my $file = $dir."$_.txt"; open my $fh, '>', $file or die "Cannot open file '$file' for writing: $!"; $dmphash{$_} = $fh; }
|
|---|