相关疑难解决方法(0)

正则表达式:如何删除Perl中字符串之间的额外空格

我正在开发一个程序,用于输入两个文件名的用户输入.不幸的是,如果用户不遵循指定的输入格式,程序很容易中断.我想编写代码来提高它对这些类型的错误的弹性.当你看到我的代码时,你会明白的:

# Ask the user for the filename of the qseq file and barcode.txt file
print "Please enter the name of the qseq file and the barcode file separated by a comma:";
# user should enter filenames like this: sample1.qseq, barcode.txt

# remove the newline from the qseq filename
chomp ($filenames = <STDIN>);

# an empty array
my @filenames;

# remove the ',' and put the files into an array separated by spaces; indexes the files
push @filename, join(' ', …
Run Code Online (Sandbox Code Playgroud)

regex perl user-input filehandle removing-whitespace

6
推荐指数
1
解决办法
2549
查看次数