So, I think this has something to do with the difference between arrays and lists, but I don't understand what is going on here. Can someone explain how and why Perl treats an expression of a type (1..4)differently than (1, 2, 3, 4)and @{[1..4]}?
(1..4)
(1, 2, 3, 4)
@{[1..4]}
$ perl -de1 Loading DB routines from perl5db.pl version 1.31 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> x scalar (1,2,3,4) 0 4 DB<2> x scalar (1..2,3,4) 0 4 DB<3> x scalar (1,2..3,4) 0 4 DB<4> x scalar (1,2,3..4) 0 '' DB<5> sub foo { (1..4) } # (the actual problem case, except 4 would be a variable) DB<6> x scalar foo() 0 '' DB<7> sub bar { @{[1..4]} } # (the workaround) DB<8> x scalar bar() 0 4
" ", , . .. - "--". -- false, false , , true, , false . ,
..
while (<>) { print if /BEGIN/ .. /END/; }
.. false, . /BEGIN/ , , , /END/. , "END", . , ( , ) "BEGIN" "END".
/BEGIN/
/END/
$., , . -- perldoc perlop.
$.
Source: https://habr.com/ru/post/1757231/More articles:How to remove a file from Subversion (make it "unversioned")? - svn.NET AES / Rijndael - inconsistent decryption when reusing the decryptor - .netCaliburn - Exception Handling and Rescue - wpfHow to send a class through a TCP connection? - javaC # Main project and links to child projects - referenceNo warning appears, although the variable is defined and the LOOKS syntax is correct - javascriptIs there something wrong with my regex? - xmlAutomatically loading Rails in the user directory - ruby-on-railsSender Equality Criteria NSNotificationCenter - objective-cWhere to place IoC container configuration? - c #All Articles