in reply to Term::Readline - are multiple histories possible?

My experiment with trying to instantiate two Term::ReadLine objects didn't work.

However, GNU ReadLine has the SetHistory function which is also documented in the perl module, so you could just set the history to whatever you want before calling readline. Instead of calling addhistory, just maintain the history for each prompt in a separate array.

Replies are listed 'Best First'.
Re^2: Term::Readline - are multiple histories possible?
by oko1 (Deacon) on Apr 07, 2008 at 23:10 UTC

    Yeah, that's one of the first things I tried myself - in several different ways. Didn't work out for me either.

    As to SetHistory, the docs say

      "SetHistory(LINE1 [, LINE2, ...])"
      sets the history of input, from where it can be used if the actual "readline" is present.
    

    That implies, to me, that the lines get saved to a "history" (however that's implemented internally) rather than allowing the option of saving to an array. I suppose I could 1) read each line as it comes in, 2) save it to the appropriate array, 3) clear the history (at each prompt) and load it from the array... but that seems like I'd be reimplementing 90% of the module just to get that extra bit of functionality.

    I'm guessing that it's possible to do this; I was just hoping that someone here would have actual experience with this aspect of the module. I'll keep grinding away at it, though, and report the results if no one else has a definite answer.

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells