Clip and extract text in clipboard-like way
version 0.0014
$data = <<_END_ # Xyzzy # --- START qwerty 1 2 3 4 5 6 8 9 10 The end # abcdefghi jklmnop _END_ $mark = Text::Clip->new( data => ... )->find( qr/#\s*--- START/ ) ( $mark, $content ) = $mark->find( qr/ The end/, slurp => '[]' )
$content =
# --- START qwerty
1 2 3 4 5 6 8 9 10 The end
Alternatively, with
( $mark, $content ) = $mark->find( qr/ The end/, slurp => '()' )
$content =
qwerty
1 2 3 4 5 6
Text::Clip allows you to mark/slice up a piece of text. String matching (by regular expression, etc.) is used to place marks. The first mark lets you access the text preceding and following the mark. Subsequent marks allow you to slurp up the text \*(L"clipped\*(R" between the marks.
Robert Krimen <[email protected]>
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.