Пожалуй, самая важная вещь, которую вы можете выучить для программирования на Perl, это контекст. Многие встроенные подпрограммы и операторы ведут себя по-разному в зависимости от контекста.
print "$query executed successfully at ", localtime, "\n"; # list context
print "$query executed successfully at ",(localtime),"\n"; # list context
print "$query executed successfully at ". localtime, "\n"; # scalar context
print "$query executed successfully at ".(localtime),"\n"; # scalar context
print "$query executed successfully at ", scalar localtime, "\n"; # scalar context
print "$query executed successfully at ", scalar (localtime),"\n"; # scalar context
Это можно сделать более ясным, разбив утверждения.
my $time = localtime; # scalar context
print "$query executed successfully at $time\n";
my @time = localtime; # list context
print "$query executed successfully at @time\n";