Question : Removing range of lines from a file

Does anyone know of a way to remove a range of lines from a file within a perl script. The 'to' and 'from' line numbers are held in 2 variables.
Any help on this would be much appreciated

Answer : Removing range of lines from a file

The flip-flop operator is useful for things like this.

This example is used as a filter (i.e. it reads from STDIN and writes to STDOUT).

my ($from, $to) = (5, 30);

while (<>) {
  print unless $. == $from .. $. == to;
}

If you can hard-code the range then it gets even easier

while (<>) {
  print unless 5 .. 20;
}


Dave...
Random Solutions  
 
programming4us programming4us