while(){ $data .= $_; } #### #!/usr/bin/perl use strict; use warnings; my $data=<) { next if $line =~ /^s*$/; #skip blank lines, common infile fault #usually at the beginning or at the end my $version = substr($line,0,3); #substr() from your code... my $jobnumber = substr($line,4,5); print "version=$version jobnumber=$jobnumber\n"; #once the above works, DBI insert code goes here... } __END__ Code above prints: version=000 jobnumber=24630 version=000 jobnumber=24630 version=000 jobnumber=24630 version=000 jobnumber=24630