How to rewrite this eval block
Posted
by est
on Stack Overflow
See other posts from Stack Overflow
or by est
Published on 2010-06-18T06:22:30Z
Indexed on
2010/06/18
6:23 UTC
Read the original article
Hit count: 247
perl
Hi,
This code smells... how do I rewrite it better?
my $record;
eval {
while (
# undef $record here, so if getRecord() failed, nothing will be written
# in the reject file
do { undef $record; defined( $record = $dataFile->getRecord ) }
) {
$LT_DataFile->encode($record);
}
1;
};
if ( my $error = $@ ) {
$rejectFile->writeRecord( $error, $record );
}
Thanks.
© Stack Overflow or respective owner