my %fh;
####
while(<>) { # the line read is stored into $_
chomp; # remove line ending character from $_
...
}
##
##
my( $data, $fh_token ) = split /\s*:\s*/;
##
##
if( ! $fh{$fh_token}) {
open my $fh, '>', "$fh_token.txt"
or die "Can't write to '$fh_token.txt': $!\n";
$fh{$fh_token} = $fh; # store filehandle
}
my $fh = $fh{$fh_token}; # this is the filehandle to print to
##
##
print $fh $data, "\n"; # append a line break. You'd use "\r\n" on windows.
##
##
my %fh;
while(<>) { # the line read is stored into $_
chomp; # remove line ending character from $_
my( $data, $fh_token ) = split /\s*:\s*/;
if( ! $fh{$fh_token}) {
open my $fh, '>', "$fh_token.txt"
or die "Can't write to '$fh_token.txt': $!\n";
$fh{$fh_token} = $fh; # store filehandle
}
my $fh = $fh{$fh_token};
print $fh $data, "\n"; # append a line break. You'd use "\r\n" on windows.
}