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

Discussion in 'Perl Misc' started by yelipolok, Jan 26, 2010.

  1. yelipolok

    yelipolok Guest

    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
    yelipolok, Jan 26, 2010
    #1
    1. Advertising

  2. "yelipolok<>" <> wrote:
    >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
    Jürgen Exner, Jan 26, 2010
    #2
    1. Advertising

  3. yelipolok

    Guest

    On Tue, 26 Jan 2010 13:37:37 -0800 (PST), "yelipolok<>" <> wrote:

    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__
    >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
    , Jan 26, 2010
    #3
  4. yelipolok

    C.DeRykus Guest

    Re: strip all but second second line from bottom and then stripthat!!!!

    On Jan 26, 1:37 pm, "yelipolok<>"
    <> wrote:
    > 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

    --
    Charles DeRykus
    C.DeRykus, Jan 27, 2010
    #4
  5. yelipolok<> wrote:
    > 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
    --
    The programmer is fighting against the two most
    destructive forces in the universe: entropy and
    human stupidity. -- Damian Conway
    John W. Krahn, Jan 27, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan
    Replies:
    1
    Views:
    8,363
    ainigma
    Apr 4, 2008
  2. Noozer
    Replies:
    1
    Views:
    7,147
    Carolyn Marenger
    Mar 13, 2006
  3. Cuthbert
    Replies:
    8
    Views:
    429
    Ancient_Hacker
    Sep 13, 2006
  4. Replies:
    0
    Views:
    276
  5. Aquila
    Replies:
    35
    Views:
    451
    Mathieu Bouchard
    Mar 31, 2005
Loading...

Share This Page