1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
while (<>)
{
# remove trailing whitespaces:
s/\s+$//;
# Remove CR and LF
s/[\r\n]//g;
if ((m/^<(.*)/) || (m/^\S+ <(.*)/))
{
# store the previous command:
if ($command ne "")
{
print "Adding: $command\n";
$response{$command} = $resp;
$ordered{$command} = $result if $ordered_received;
$resp = "";
$result = "";
$ordered_received = 0;
$command = "";
}
# a new command line:
$command = $1;
if ($command =~ /;/)
{
$command = uc($command) unless $case_sensitive;
}
}
elsif ($ordered_received)
{
# collect the result lines
$result .= "$_\r\n";
}
else
{
# collect the response lines
$resp .= "$_\r\n";
}
}
1 2 3 4 5 6 7 8 9 10
my $command = ''; for my $line (@d) { if ($line =~ /^<(.+)/ ... $line =~ /^<($command)/) { $command = $1; say "REIN ".$command.' '.$line; } else { say "RAUS ".$command.' '.$line; } }
1 2 3 4 5 6 7 8 9
my %result = (); my $command = ''; for my $line (@d) { if ($line =~ /^<(.+)/) { $command = $1; } $result{$command} .= $line; }
if ($1 eq qr{^\S+;})
if ($1 =~ qr{^\S+;})
if ($1 ~~ qr{^\S+;})