in reply to substr on $_

I'm pretty big on checking the validity of the data that I get as well as doing the correct kind of actions with it. Perl is naturally magnificent at doing both in one fell swoop:

#!/usr/local/bin/perl -w use strict; while (my $val = <DATA>) { chomp $val; print "Read: $val - "; # Only accept input values which consist of NNNN.NNNNN, one per lin +e if ($val =~ s/^\d{2}(\d{2})\.(\d{5})$/$1$2/) { print "format OK, changed to $val.\n"; } else { print "item $val not in YYYY.NNNNN format.\n"; } } __DATA__ 1996.40637 1996.41064 1996.41199 1996.41467 1996.41882 11996.41882 1997.418828 1998.4128