The simple implementation of this is like below. Keep a record of whether the "start" has happened yet. And if it has, then print all the lines after that and including that one.

code example and output.. click below..

#!/usr/bin/perl -w use strict; my $seen_once =0; while (<DATA>) { $seen_once =1 if (m/^\*/); print if $seen_once; } =prints: the line "Gain... " IS NOT PRINTED *Check if your claims have been finalized. *Sign up for alerts about your claim activity. *Print a temporary ID card. *View up to 18 months of claim payment details. *Much, much more! In addition you, your spouse and children can: *Search for Doctors and Hospitals in your area. *Begin a program to stop smoking or lose weight. *Learn more about a specific disease or condition". =cut __DATA__ "Gain immediate access and... *Check if your claims have been finalized. *Sign up for alerts about your claim activity. *Print a temporary ID card. *View up to 18 months of claim payment details. *Much, much more! In addition you, your spouse and children can: *Search for Doctors and Hospitals in your area. *Begin a program to stop smoking or lose weight. *Learn more about a specific disease or condition".
More specific version of your code:
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.


In reply to Re^3: Extracting data from a particular line to end of the file by Marshall
in thread Extracting data from a particular line to end of the file by manne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.