I am extracting the language codes from some MARC records using the leader (field 008), position 35 and three characters long. The code works fine as long as the 008 does have a language code in it. However, if there is no language code, I want to assign the code "ENG". The problem is my test for an empty language code is not working. I've tried a few variants of the regex, but come up empty handed. When I print out the empty language code it is just three blank spaces, but my regex isn't picking that up. Any ideas would be greatly appreciated.
Here's the code snippet: ## get the language code from the 008 field my $leader = $record->field('008'); my $language = uc(substr($leader->as_string, 35, 3)); ### If there is no language code in the 008, assign ENG for ENGLISH if($language =~ /[^A-Z]/ ) { ## I've also tried /^$/ and /[A-Z]{3}/ and a non regex comparison of $language == " " $lang = "ENG"; } else { $lang = $language; ## from above -- Migell Acosta migell.aco...@gmail.com