index($buf, "/DATA_String/") > 0
####
index($buf, "/DATA_String/") > -1
####
$ perl -E '
my @strings = qw{
no_data_string
/DATA_String/
X/DATA_String/
/some/path/to/DATA_String/
};
say "-" x 40;
for my $string (@strings) {
say "\$string[$string]";
for my $pos (qw{0 -1}) {
say "\$pos[$pos]";
if (index($string, "/DATA_String/") > $pos) {
say "index() TRUE";
}
else {
say "index() FALSE";
}
}
say "-" x 40;
}
'
####
----------------------------------------
$string[no_data_string]
$pos[0]
index() FALSE
$pos[-1]
index() FALSE
----------------------------------------
$string[/DATA_String/]
$pos[0]
index() FALSE
$pos[-1]
index() TRUE
----------------------------------------
$string[X/DATA_String/]
$pos[0]
index() TRUE
$pos[-1]
index() TRUE
----------------------------------------
$string[/some/path/to/DATA_String/]
$pos[0]
index() TRUE
$pos[-1]
index() TRUE
----------------------------------------
####
...
use strict;
use warnings;
use autodie;
use IO::Socket;
{
open my $pid_fh, '>', '/var/run/aws.rcvr.pid';
print $pid_fh "$$\n";
}
my ($sock, $new_sock, $buf );
$sock = IO::Socket::INET::->new(...);
...