Here's an example of a some code that will take a defined "pattern" for a datafile, and then parse input from the datafile based on the pattern. It could probably be trimmed up a lot, but it may be useful!

#it definately needs a little cleanup later... if (! $in{'batchfile'} ) { die("You must select a file to be uploaded"); } else { #Any formatting information. Text or numbers are grabbed as fi +elds #This can be in almost ANY format/order as you want, so long #as text/numbers are only used as fields, and no weird need-to +-be-escaped #stuff #(note: you could modify this to grab it as the first line fro +m the uploaded file) $format=$in{'format'}; #Batchfile is the data input file $data=$in{'batchfile'}; my @records; $reg_format_in=$format; #replace any words/numbers with a regexp... $reg_format_in =~ s/([\w|\d]+)/\(\[\\w\|\\d\]\+\)/gi; #replace any spaces with a regexp for spaces $reg_format_in =~ s/\s+/\\s\+/gi; $_ = $format; my $order=0; my @matches; #go through each matched pattern, mark the index and what was +in that position while ( m/([\w|\d]+)/g) { $matcheditem=$1; $indx =index($format, $matcheditem); $matches[$order]=$matcheditem; $order++; } $matchcount=@matches; @lines = split(/\n/, $data); foreach $line(@lines) { my $pattern; $_ = $line; my @rmatch = m/^$reg_format_in/g; $reccount=@records; #this makes a $records[x]{name} per each line for (my $indx=0; $indx<$matchcount; $indx++) { $records[$reccount]{$matches[$indx]}=$rmatch[$indx]; } } }