in reply to Need to skip two lines

Will this solve your problem?
#!/usr/bin/perl use strict; my $skip_count = 0; while (<DATA>) { if ( $skip_count > 0 ) { $skip_count--; next; } $skip_count = 2 if ( /^abc/ ); print; } __DATA__ def abc skip_1 skip_2 xyz

Replies are listed 'Best First'.
Re^2: Need to skip two lines
by codeacrobat (Chaplain) on May 06, 2009 at 05:52 UTC
    This is how you skip lines without affecting the rest of the outer while loop.
    while(<DATA>){ if (/2/){ my $skip=2; print "skipping $skip lines\n"; <DATA> while $skip-- >0 and not eof DATA; next; } if (/5/){ print "high five\n"; next; } if (/3/){ print "I am not here\n"; next; } print; } __DATA__ 1 1 2 3 4 4 5

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
Re^2: Need to skip two lines
by drodinthe559 (Monk) on May 05, 2009 at 22:55 UTC
    I think that might work. Let me put that in my script to see what happens. Thanks, Dave