in reply to Keep only X number of entries of a file using a delimeter

I imagine your input looks like this:
# Entry 1 ... # Entry 2 ...

You can use $/ aka the Input record separator:

perl -pe 'BEGIN { $/ = "#" } exit if $. > 500' input-file

$. contains the record number.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Keep only X number of entries of a file using a delimeter
by Anonymous Monk on Oct 13, 2015 at 14:19 UTC
    Hi,
    interesting approach! Could you please re-write this to a "normal" script (i.e. not one-liner)?
      Sure. Just add
      -MO=Deparse
      before the switches.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ