strip all but second second line from bottom and then strip that!!!!

Y

yelipolok

I cannot figure it out, but I know it's very simple for perl.

Here's the text, below the cut mark. There's a typical \n at the end
of each line.

--
info depth 9
info depth 9
info depth 9 seldepth 30 score cp 31 lowerbound time 59 nodes 80142
nps 1358000 pv f6f3 e2f3
info depth 9
info depth 9 seldepth 30 score cp 17 time 61 nodes 82240 nps 1348000
pv f6f3 e2f3 c6d4 f3e3
info depth 10
info depth 10 seldepth 32 score cp 25 lowerbound time 91 nodes 126058
nps 1385000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 32 score cp 33 lowerbound time 111 nodes 156296
nps 1408000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 33 score cp 34 time 144 nodes 205129 nps
1424000 pv f6f3 e2f3 c6d4 f3e3
info depth 10 seldepth 33 score cp 34 time 154 nodes 216834 nps
1408000 pv f6f3 e2f3 c6d4 f3e3
bestmove f6f3 ponder e2f3
--

I want to strip it all EXCEPT for the the line second from bottom and
then just the part from "pv to the end of line"

Result being: f6f3 e2f3 c6d4 f3e3

Thanks
 
J

Jürgen Exner

yelipolok said:
I cannot figure it out, but I know it's very simple for perl.

Here's the text, below the cut mark. There's a typical \n at the end
of each line.

-- [...]
info depth 10 seldepth 33 score cp 34 time 144 nodes 205129 nps
1424000 pv f6f3 e2f3 c6d4 f3e3
info depth 10 seldepth 33 score cp 34 time 154 nodes 216834 nps
1408000 pv f6f3 e2f3 c6d4 f3e3
bestmove f6f3 ponder e2f3

Open the file, slurp the text into an array @lines, grab
$lines[@lines-1], and split on space character like

(undef, undef, $result) = split / /, $lines[@lines-1], 3;

jue
 
S

sln

This is an initial interpretation. Depends on what you mean "EXCEPT ..."

-sln

--------------
use strict;
use warnings;

{
local $/;
print $1 if <DATA> =~ /.*pv\s*([a-f0-9 ]+)$/ims;
}

__DATA__
 
C

C.DeRykus

I cannot figure it out, but I know it's very simple for perl.

Here's the text, below the cut mark.  There's a typical \n at the end
of each line.

--
info depth 9
info depth 9
info depth 9 seldepth 30 score cp 31 lowerbound time 59 nodes 80142
nps 1358000 pv f6f3 e2f3
info depth 9
info depth 9 seldepth 30 score cp 17  time 61 nodes 82240 nps 1348000
pv f6f3 e2f3 c6d4 f3e3
info depth 10
info depth 10 seldepth 32 score cp 25 lowerbound time 91 nodes 126058
nps 1385000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 32 score cp 33 lowerbound time 111 nodes 156296
nps 1408000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 33 score cp 34  time 144 nodes 205129 nps
1424000 pv f6f3 e2f3 c6d4 f3e3
info depth 10 seldepth 33 score cp 34  time 154 nodes 216834 nps
1408000 pv f6f3 e2f3 c6d4 f3e3
bestmove f6f3 ponder e2f3
--

I want to strip it all EXCEPT for the the line second from bottom and
then just the part from "pv to the end of line"

Result being:    f6f3 e2f3 c6d4 f3e3

perl -ne 'if(eof){($_=$l) =~s /1408000 pv //;print }else{$l=$_}'
infile
 
J

John W. Krahn

yelipolok said:
I cannot figure it out, but I know it's very simple for perl.

Here's the text, below the cut mark. There's a typical \n at the end
of each line.

--
info depth 9
info depth 9
info depth 9 seldepth 30 score cp 31 lowerbound time 59 nodes 80142
nps 1358000 pv f6f3 e2f3
info depth 9
info depth 9 seldepth 30 score cp 17 time 61 nodes 82240 nps 1348000
pv f6f3 e2f3 c6d4 f3e3
info depth 10
info depth 10 seldepth 32 score cp 25 lowerbound time 91 nodes 126058
nps 1385000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 32 score cp 33 lowerbound time 111 nodes 156296
nps 1408000 pv f6f3 e2f3
info depth 10
info depth 10 seldepth 33 score cp 34 time 144 nodes 205129 nps
1424000 pv f6f3 e2f3 c6d4 f3e3
info depth 10 seldepth 33 score cp 34 time 154 nodes 216834 nps
1408000 pv f6f3 e2f3 c6d4 f3e3
bestmove f6f3 ponder e2f3
--

I want to strip it all EXCEPT for the the line second from bottom and
then just the part from "pv to the end of line"

Result being: f6f3 e2f3 c6d4 f3e3

use File::ReadBackwards;

my $bw = File::ReadBackwards->new( 'filename' )
or die "Cannot read 'filename' $!";

while ( defined( my $line = $bw->readline ) ) {
if ( $line =~ /\bpv ([\s0-9a-fA-F]+)/ ) {
print $1;
last;
}
}




John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top