在Perl中是否有正则表达式来查找文件的扩展名?例如,如果我有" test.exe",我怎么会得到" .exe"?
确切的错误:
$ ./script.pl file.txt
Can't open file.txt: No such file or directory at ./script.pl line 17.
Use of uninitialized value in chomp at ./script.pl line 17.
Username: Password:
Run Code Online (Sandbox Code Playgroud)
我正在编写一个脚本,从命令行获取文件名,然后将其输出写入它:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ReadKey;
my @array;
my $user;
my $pass;
# get login info
print "Username: ";
chomp($user = <>); # line 17
print "Password: ";
ReadMode 2;
chomp($pass = <>);
ReadMode 0;
print " \n";
# ...
# connect to database, and save the info in "@array" …Run Code Online (Sandbox Code Playgroud)