open (my $file1,"<$dir/seq.results") or die "cannot open "$dir/seq.res
+ults";
open (my $file2,">$dir/seq.out") or die "cannot open $dir/seq.out" for
+ write";
my $started =0;
while (<$file1>)
{
$started =1 if (m/^\*/); #first line starting with * is seen
print $file2 "$_" if $started;
}
Note: '*' has special meaning within a regex and it has to be "escaped" to get the literal value of '*'.
Yes, there are ways of coding this in a more brief way. But do not confuse brevity with execution efficiency and certainly not clarity.
Oh, in a very simple program like this (6 lines), there is no need to explicitly close the file handles ($file1 and $file2). The OS will do that for you when the program exits. In longer programs there can be good reasons to do that. |