i have a file with contents like
<<< file1: abcd.c
>>> file2: abcd.cx
--------[after 12]-----|-----------[inserted 67-80]------
---------[deleted 67-89]---|---------[after 56]----------
<<< file1: def.c
how do i select only lines that come in between >>> and
<<<
ie.,
--------[after 12]-----|-----------[inserted 67-80]------
---------[deleted 67-89]---|---------[after 56]----------
and from this i would like to take out the
12 67-80
67-89 56
i appreciate the prompt from goboating and i thank him for the same.and it gave me some idea but the expression
($buffer =~ />>>(.*?)<<</gs) is not working please help me at your earliest
what will happen when $chunk = $1; I am new to perl may be the doubt is silly but i would like to get it clarified...as nothing was printed on STDOUT
when i gave print " $chunk";
=============================================================================
solution by goboating
==================================================
I have not run this, but it should be pretty close. Inside the inner most 'while', do what ever you like with the numbers.
open(IPF,"<inputFile"
or die "Failed to open inputFile, $!\n";
while (<IPF>) { $buffer .= $_; }
close IPF;
# while matching stuff between >>> and <<<
while ($buffer =~ />>>(.*?)<<</gs)
{
# catch matched strings in $chunk
$chunk = $1;
{
while ($chunk =~ /\[\w+ (.*?)\]/gs) { $numbers = $1; }
}
}
'hope this helps
<<< file1: abcd.c
>>> file2: abcd.cx
--------[after 12]-----|-----------[inserted 67-80]------
---------[deleted 67-89]---|---------[after 56]----------
<<< file1: def.c
how do i select only lines that come in between >>> and
<<<
ie.,
--------[after 12]-----|-----------[inserted 67-80]------
---------[deleted 67-89]---|---------[after 56]----------
and from this i would like to take out the
12 67-80
67-89 56
i appreciate the prompt from goboating and i thank him for the same.and it gave me some idea but the expression
($buffer =~ />>>(.*?)<<</gs) is not working please help me at your earliest
what will happen when $chunk = $1; I am new to perl may be the doubt is silly but i would like to get it clarified...as nothing was printed on STDOUT
when i gave print " $chunk";
=============================================================================
solution by goboating
==================================================
I have not run this, but it should be pretty close. Inside the inner most 'while', do what ever you like with the numbers.
open(IPF,"<inputFile"
while (<IPF>) { $buffer .= $_; }
close IPF;
# while matching stuff between >>> and <<<
while ($buffer =~ />>>(.*?)<<</gs)
{
# catch matched strings in $chunk
$chunk = $1;
{
while ($chunk =~ /\[\w+ (.*?)\]/gs) { $numbers = $1; }
}
}
'hope this helps