Re: perl wrapper for yaz-marcdump

From: Jay Luker <jay.luker_at_nyob>
Date: Fri, 30 Jan 2009 16:39:35 -0500
To: CODE4LIB_at_LISTSERV.ND.EDU
On Fri, Jan 30, 2009 at 4:12 PM, Eric Lease Morgan <emorgan_at_nd.edu> wrote:

>
>    # run yaz and trap the output
>    open ( C, "$y$f |" ) or die "Can't open converter: $!\n";
>    while ( <C> ) { $r = $_ }
>    close C;
>
>
> For extra credit, is there anyway I can optimize m2u? For example, is there
> anyway to get rid of the while loop and slurp up yaz-marcdump's output in
> one go?


You can replace the while loop with perl's usual slurp idiom:

$r = do { local $/; <C> };

Explained here:
http://www.perlmonks.org/?node_id=287647

--jay
Received on Fri Jan 30 2009 - 16:40:38 EST