in reply to use of substr() with file

You had an uninitialized value in your regex. Hmm... here's an easier way:
#!/usr/bin/perl use strict; use warnings; my $line = '<head><to>toe</to></head>'; print substr($line, 10, 3), "\n";