#!/usr/bin/perl -w use strict; $| =1; my $curve1_out = 'curve1.out'; my $curve2_out = 'curve2.out'; my $in ='curve12.data'; open (IN, '<', $in) or die "cannot open $in $!"; open (my $c1, '>', $curve1_out) or die "cannot open $curve1_out $!"; open (my $c2, '>', $curve2_out) or die "cannot open $curve2_out $!"; while () { if (/^Curve(\d):/.../^\s*$/) { if (defined($1) && $1==1 && /^\d/) {print $c1 "$_\n";}; if (defined($1) && $1==2 && /^\d/) {print $c2 "$_\n"}; } }