1

次のように、ユーザー入力をプログラムに読み込むために使用しようとしています。

#!/usr/bin/perl -w
use strict; 

if ($#ARGV == 0) { 
print "What condition are you sorting?\t";
chomp(my $condition = <STDIN>);

# Use $condition in further blocks of code...

}

これは機能しています。ただし、同様の方法で使用する 2 つ (またはそれ以上) の値を入力する方法がわからない場合。例えば

if ($#ARGV == 1) {  
print "What conditions are you comparing?\t";
chomp(my $condition1 = <STDIN>);
chomp(my $condition2 = <STDIN>);

2 回入力できますが、書式が歪んでいます。

What conditions are you comparing?  <condition1>
<condition2>
4

1 に答える 1