## Forum archive 2000-2006

### Nandor Sieben - $ml->dumpExtra = ""; # gives error ### Nandor Sieben -$ml->dumpExtra = ""; # gives error

by Arnold Pizer -
Number of replies: 0
 $ml->dumpExtra = ""; # gives error topic started 6/7/2005; 1:28:10 AMlast post 6/8/2005; 3:09:48 PM  Nandor Sieben -$ml->dumpExtra = ""; # gives error  6/7/2005; 1:28:10 AM (reads: 810, responses: 2) I am trying to create a new_match_list problem. Everything works except the dumpExtra command which gives an error. I have found this command in the docs for Match.pm. Is this the correct syntax? I also tried $ml->dumpExtra(""); # has no effect Nandor <| Post or View Comments |>  Davide P. Cervone - Re:$ml->dumpExtra =  6/7/2005; 7:53:24 PM (reads: 1063, responses: 0) It probably would help if you told us the error message that you are seeing. It might also be useful to tell us what you are trying to do, as we might be able to suggest an alternative. The only reference I see in the documents for Match.pm is  Note that unused answers are dumped into the list of extra 'answers' so the indexing may be difficult to grasp at first. (This can be stopped by doing the following: $ml->dumpExtra = "";) but this is probably in error, as dumpExtra is a function, not a variable, so can't be assigned to in this way. If you are trying to prevent unused answers from being added to the extra answers (not clear from your question), then I can suggest three ways. First, you could make your own subclass of the Match object and override the dumpExtra method:  package MyMatch; out @ISA = qw(Match); sub dumpExtra {}; package main;$ml = new MyMatch(...); This would make dumpExtra do nothing. Another alternative is that, since dumpExtra is only called from the choose method, you could just do what it does, but leave out the call to dump. For example:  $ml->getRandoms(scalar(@{$mlf->{questions}}), choose-arguments); $ml->selectQA();$ml->condense(); where choose-arguments is the list of argument you normally would have passed to $ml->choose() Finally, you could call $ml->choose() as normal and try to undo the effect of dumpExtra by popping off the extra questions that have been added to the list.  $ml->choose(...); split(@{$ml->{extras}},scalar(@{ml->{slice}})-scalar(@{$ml->{answers}})); (I haven't tested any of this code, so you may need to adjust it.) Hope that helps. Davide <| Post or View Comments |>  Nandor Sieben - Re:$ml->dumpExtra =  6/8/2005; 3:09:48 PM (reads: 1030, responses: 0) I experimented with the third option. I think this works: $ml = new_match_list();$ml->qa( "What color is a rose?", "Red", "What color is the sky?", "Blue", "What color is grass?", "Green", "$$a^2$$", "$$aa$$", ); # choose three of these questions, ordered at random $ml->choose(3); # the answers not chosen become extra answers # careful with this, all the answers need to be different # to erase these extra answers do this @{$ml->{extras}}=(); $ml->extra("This is a bad answer", 'Do not pick me', 'Horrible answer' );$ml->choose_extra(2); Nandor <| Post or View Comments |>