use strict; use warnings; use MARC::Charset 'marc8_to_utf8'; # well ... seems to work :) MARC::Charset->ignore_errors(1); my @header; while ( my $line = <> ) { if ( my ($charset) = $line =~ /^\d CHAR (\w+)/m ) { if ( $charset eq 'ANSEL' ) { binmode(STDOUT, 'utf8'); print marc8_to_utf8($_) while $_ = shift @header; print marc8_to_utf8($_) while <>; } else { warn "can't convert $charset\n"; exit 1; } } if ( $line =~ /^\d @/ ) { warn "line $. : charset not found \n"; exit 2; } push @header,$line; }