It seems to be too greedy.
Quite right. You can make it less greedy by using the ? character.
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my $text = <<EOT; Any text is in this document. But I'm only interested in the text between a beginning and an end tag +. BEGIN_TAG_110 In this text I'm interested in. It can consist of several lines. Until the end tag. END_TAG and any other things I'm not interested in until the next begi +nning tag starts. Any other text. BEGIN_TAG_237 I need this text. END_TAG More text ... EOT my %res = $text =~ /BEGIN_TAG_(\d+)(.*?)END_TAG/sg; print Dumper (\%res);
That should get you started anyway.
🦛
In reply to Re: Get text between start and end tag
by hippo
in thread Get text between start and end tag
by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |