in reply to Uninitialized value in substr command

Here is the code I've written to do it. My problem is, every time I run it, I get a million errors that all say "Use of uninitialized value in substr at line 19." But I can't figure out what value it's talking about.
Why, it's obvious.
do { ++$element2; } until (substr($contigfile[$element2], 0, 1) eq '>');

If $configfile[$element2] yields undef, the loop will never stop. Because substr( undef, 0,  1 ) eq '>' is never true.

perl -we 'do { print "hello\n" } until substr( undef, 0, 1 ) eq ">"' hello Use of uninitialized value in substr at -e line 1. hello Use of uninitialized value in substr at -e line 1. hello Use of uninitialized value in substr at -e line 1. hello Use of uninitialized value in substr at -e line 1. hello ...