私は Perl を初めて使用し、この特定の問題に対する答えを見つけることができませんでした。私はいくつかのテキストを解析しています。行のエントリの一部を他の行の入力として使用したいと考えています。以下では、「M」で始まるメッセージに $sec を使用したいと考えています。私のコードは次のとおりです。
#identify the type of message here:
my $message = substr $_, 0, 1;
if ($message eq "T") {
my $sec = substr $_, 1, 5;
#no ms entry here
my $ms = 66666;
push @add_orders, $_;
print add_order_file "$sec, $ms\n";
}
if ($message eq "M") {
my $ms=substr $_, 1, 3;
push @add_orders, $_;
#I want $sec to be from the previous
print add_order_file "$sec, $ms \n";
}