I am working on a program that take user input for two file names. Unfortunately, the program can easily break if the user does not follow the specified format of the input.
While I think your design is a little iffy, the following will work?
my @fileNames = split(',', $filenames); foreach my $fileName (@fileNames) { if($fileName =~ /\s/) { print STDERR "Invalid filename."; exit -1; } } my ($qsec, $barcode) = @fileNames;