in reply to Assistance with Comma parse
#!/usr/bin/perl use strict; use warnings; my $file = ""; my $fh; while (<>) { my ($node, $mess) = split /,/ => $_, 2; unless ($node eq $file) { close $fh or die "close $file: $!" if $fh; $file = $node; open $fh => '>', $file or die "open $file: $!"; } print $fh $mess; } __END__
Or from the command line:
perl -apF, -e'if($F ne$F[0]){$F=$F[0];open F,">$F"or die;select F}s/[^ +,]+//'
Abigail
|
|---|