in reply to Re^2: processing a lot of files
in thread processing a lot of files

I'll bet you have lines in your data files that don't match the regex, so the $1 and $2 values are undefined, then you try to use them in the print statement. One solution is to simply cleanup the input files before running the script (i.e., make sure there are no files in the input directory other than files you want the script to process). The other possibility is that your data has junk in it - maybe blank lines or comment lines? If so, you simply need to check for those and skip them as needed.

while(my $line = <$in>) { chomp $line; $line =~ s/^\s+//; # strip leading whitespace next unless $line; # skip blank lines next if ($line =~ /^#/; # skip comment line ... }

Another thing you can do is this:

my ($x, $y) = $sample =~ /(\d+)(.*)/; $x = '?' unless $x; $y = '?' unless $y;

This saves the regex matches into variables, so you don't have to use the special vars $1 and $2 anymore, and you can test them, give them default values, etc.