Perhaps the most important thing you can learn for programming in Perl, is context. Many built-in subroutines, and operators, behave differently depending on the context.
print "$query executed successfully at ", localtime, "
"; # list context
print "$query executed successfully at ",(localtime),"
"; # list context
print "$query executed successfully at ". localtime, "
"; # scalar context
print "$query executed successfully at ".(localtime),"
"; # scalar context
print "$query executed successfully at ", scalar localtime, "
"; # scalar context
print "$query executed successfully at ", scalar (localtime),"
"; # scalar context
This can be made clearer by splitting up the statements.
my $time = localtime; # scalar context
print "$query executed successfully at $time
";
my @time = localtime; # list context
print "$query executed successfully at @time
";
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…