W
Wenjie
Hello,
I have a task to check things within some block in a file:
----%<-----
# this is the block to be analyzed:
{
Item one;
Item two
} quantity: 3
----%<-----
I want to get:
a):
Item one;
Item two
b): a) has quantity 3
Text::Balanced seems to be useful but I have met the problem to
specify "prefix":
use Text::Balanced qw(extract_bracketed);
use strict;
my $objfile = shift;
open (PAT, "< $objfile") or die "couldn't open $objfile for reading: $!\n";
my $text;
{
local $/;
$text = <PAT>;
}
my ($extracted, $remainder) =
extract_bracketed ($text, '{', "What_to_fill_here_?");
# What to do to extract quantity for the block?
Thanks for your helps,
Wenjie
I have a task to check things within some block in a file:
----%<-----
# this is the block to be analyzed:
{
Item one;
Item two
} quantity: 3
----%<-----
I want to get:
a):
Item one;
Item two
b): a) has quantity 3
Text::Balanced seems to be useful but I have met the problem to
specify "prefix":
use Text::Balanced qw(extract_bracketed);
use strict;
my $objfile = shift;
open (PAT, "< $objfile") or die "couldn't open $objfile for reading: $!\n";
my $text;
{
local $/;
$text = <PAT>;
}
my ($extracted, $remainder) =
extract_bracketed ($text, '{', "What_to_fill_here_?");
# What to do to extract quantity for the block?
Thanks for your helps,
Wenjie