我目前正在尝试弄清楚如何让我的 perl 脚本同时接受字母的小写和大写变体。
例如。
my %channels = (a => 'test', b => 'test2', c => 'test3', d => 'test4', e => 'test5', f => 'test6', g => 'test7');
所以当我想参加考试时,我可以做 a 或 A 并且它会接受它
总结一下问题:
在运行脚本时,我遇到了一个问题,如果你想测试,你必须输入一个。这对我来说没什么问题,但其他人想要选择做资本 A。我正试图让他们选择这样做。
谢谢大家
最佳答案
对于您的散列键( 单字母作为键 )尝试逻辑定义的运算符。
// => logical defined operator. If the left hand side is true give the result else if evaluate the right side.
print $channels{$input} // $channels{lc($input)};
关于perl - 如何让 Perl 识别小写和大写输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39031864/