How the next grep function works (what does !/0o1Iil]/?)
!/0o1Iil]/
@chars = grep !/0o1Iil]/, 0..9, "A".."Z", "a".."z"; use Data::Dumper; print Dumper @chars;
to create the following in @chars?
$VAR1 = 0; $VAR2 = 1; $VAR3 = 2; $VAR4 = 3; $VAR5 = 4; $VAR6 = 5; $VAR7 = 6; $VAR8 = 7; $VAR9 = 8; $VAR10 = 9; $VAR11 = 'A'; $VAR12 = 'B'; $VAR13 = 'C'; $VAR14 = 'D'; $VAR15 = 'E'; $VAR16 = 'F'; $VAR17 = 'G'; $VAR18 = 'H'; $VAR19 = 'I'; $VAR20 = 'J'; $VAR21 = 'K'; $VAR22 = 'L'; $VAR23 = 'M'; $VAR24 = 'N'; $VAR25 = 'O'; $VAR26 = 'P'; $VAR27 = 'Q'; $VAR28 = 'R'; $VAR29 = 'S'; $VAR30 = 'T'; $VAR31 = 'U'; $VAR32 = 'V'; $VAR33 = 'W'; $VAR34 = 'X'; $VAR35 = 'Y'; $VAR36 = 'Z'; $VAR37 = 'a'; $VAR38 = 'b'; $VAR39 = 'c'; $VAR40 = 'd'; $VAR41 = 'e'; $VAR42 = 'f'; $VAR43 = 'g'; $VAR44 = 'h'; $VAR45 = 'i'; $VAR46 = 'j'; $VAR47 = 'k'; $VAR48 = 'l'; $VAR49 = 'm'; $VAR50 = 'n'; $VAR51 = 'o'; $VAR52 = 'p'; $VAR53 = 'q'; $VAR54 = 'r'; $VAR55 = 's'; $VAR56 = 't'; $VAR57 = 'u'; $VAR58 = 'v'; $VAR59 = 'w'; $VAR60 = 'x'; $VAR61 = 'y'; $VAR62 = 'z';
Here is grep perldoc . The example in your example uses syntax grep EXPR,LIST, which means that any Perl expression can replace EXPR.
grep EXPR,LIST
EXPR
grep takes the list provided to it and returns only those elements where EXPR is true.
EXPR ! /0o1Iil]/ ( ), , /0o1Iil]/. ( 0o1Iil]), .
! /0o1Iil]/
/0o1Iil]/
0o1Iil]
, , , /[0o1Iil]/, , , . 0 o, 1 I. ..
/[0o1Iil]/
Btw, grep BLOCK LIST :
@chars = grep { ! /[0o1Iil]/ } (0..9, 'A'..'Z', 'a'..'z');
// - . !/[0o1Iil]/ , " ". , ([) - , , (0/O, I/l/1).
//
!/[0o1Iil]/
[
Perl grep:
grep BLOCK LIST
BLOCK LIST , , true.
BLOCK
LIST
BLOCK !/0o1Iil]/, true , 0o1Iil]. LIST , grep LIST.
BLOCK : !/[0o1Iil]/, true , 0 1 ai al, LIST , , .
grep .
grep
- - .
. ! not. , , .
!
not
0o1Iil] (not 0o1Iil, [ ] .
0o1Iil
]
grep {not /0o1Iil]/} 0..9, A..Z, a..z ( [):
grep {not /0o1Iil]/} 0..9, A..Z, a..z
, 0..9, A..Z, a..z 0o1Iil], , - .
0..9, A..Z, a..z
grep {not /[0o1Iil]/} 0..9, A..Z, a..z ( [):
grep {not /[0o1Iil]/} 0..9, A..Z, a..z
, 0, o, 1, I, I l . , - , .
0
o
1
I
l
Source: https://habr.com/ru/post/1737826/More articles:function binding and clone () function - jQuery - functionjQuery - datepicker - onblur - javascriptIn PHP: How to call the $ variable inside one function that was previously defined inside another function? - functionWhat is HTML5 canvas? - javascriptSoftware fault tolerance accuracy - fault-toleranceAfter creating a managed domain with MVVM / WPF - design-patternsDirectives order [BITS 16] and [ORG 0x0000] - assemblyHow to turn a Java class into one of its subclasses (SocketAddress and InetSocketAddress) - javaHow can I build something like Amazon S3 in Perl? - filePress Tabbar to open the email view in iphone. - iphoneAll Articles