Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting lines with the perl match operator 1

Status
Not open for further replies.

olded

Programmer
Oct 27, 1998
1,065
US
Using perl's matching operator, I can extract lines 3, 6, and 9 from a file:

Code:
perl -wnl -e 'print if $. !~ m/^(3|6|9)$/' datafile.txt

Is there syntax for the matching operator that allows deleting a range of lines, say from 3 to 9?

Thanks!

Ed
 
Why not simply use the > and < operators.

Code:
if $. < 3 || $. > 9

- Miller
 
feherke:

Thank you. That was helpful.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top