LONDON (AFP) - Irish author and playwright Sebastian Barry on Tuesday won the 25,000-pound Costa Book of the Year award for his novel "The Secret Scripture", the judges said " even though they disliked the ending. Chairman of the judges Matthew Parris revealed the panel was split on whether to give the prize " worth 27,000 euros or 35,000 dollars " to Barry or Adam Foulds for his debut work of poetry, "The Broken Word", partly because of "the unanimity that the ending didn't work" in Barry's book. However, Parris added: "There was a feeling amongst a lot of the judges that many great works are also flawed. (Shakespeare's) The Tempest, after all " the ending isn't very good." "The Secret Scripture" tells the story of the ageing Roseanne McNulty and her family in 1930s Ireland through her memories and those of her psychiatrist in the hospital where she has spent most of her adult life. As she prepares for the closure of the institution, the pair develop an intense relationship and reveal the past through their journals. Parris said: "Most people thought that in Roseanne a narrator had been created of such a transcendence that that redeemed all the other structural weaknesses in the book." Barry was shortlisted for the Booker Prize last year but lost out to Aravind Adiga, who took the award for his novel "The White Tiger". Accepting the award, he said "The Secret Scripture" was inspired by something that happened to his great-aunt in the 1930s and 1940s. "The ending of the book was my effort to recompense her, to give something back. Whether that's a flaw I don't know," he said. The Costa Book Award, formerly the Whitbread Book Award, was established in 1971 to celebrate contemporary British and Irish writing. A panel of writers, actors and broadcasters choose the most enjoyable books from the past year. The others on the shortlist were Sadie Jones for her debut novel "The Outcast", Diana Athill for her memoir "Somewhere Towards the End", and Michelle Magorian, the author of "Goodnight Mr Tom", for her new novel "Just Henry".