Using the truck does not cause a failure

when running the code as follows:

use strict;
print Dumper "something";

nothing is printed, and no errors occur during compilation and runtime. Why is this happening? Why strictprevents this code from running? Why are there no errors at run time, although Dumper is unknown?

I know that it gives a warning when they are explicitly included, but I wonder why this code is considered “correct” in any way.

+2
source share
2 answers

One of the valid syntax for print-

print FILEHANDLE LIST

In your program, Perl processes Dumperlike a file descriptor globe.

Running this code with warnings turned on will tell you:

print() on unopened filehandle Dumper at ...

+7
source

, :

#!/usr/bin/env perl
#
# name_of_program - what the program does as brief one-liner
#
# Your Name <your_email@your_host.TLA>
# Date program written/released
#################################################################

use 5.10.0;

use utf8;
use strict;
use autodie;
use warnings FATAL => "all";

#  ⚠ change to agree with your input: ↓
use open ":std" => IN    => ":encoding(ISO-8859-1)",
                   OUT   => ":utf8";
#  ⚠ change for your output: ↑ — *maybe*, but leaving as UTF-8 is sometimes better

END {close STDOUT}

our $VERSION = 1.0;

$| = 1;

, , . "something" Dumper, Dumper print. Dumper print s invocant. , .

. !

+11

Source: https://habr.com/ru/post/1786153/


All Articles