} elsif( /^(\#?\s*(?:pickup|qmgr)\s+)(?:fifo|unix)(\s+.*)/ ) { if( defined $normalize->{$1} ) { next; } else { $normalize->{$1} = 1; }
if the string starting at the beginning of the line matches, $1 will contain "zero or one #, zero or more whitespaces, either the word "pickup" or "qmgr", one or more whitespace" - it's then being used as the kev value in the hash referenced by $normalize - if that entry already has a true value (probably a 1) don't do anything, otherwise, assign that key a 1 . Note, to fully match, that string has to be followed by either "fifo" or "unix" and 1 or more whitespaces. Everything (including those last whitespaces) will end up $2. I'm a tad puzzled as to what the purpose could be, there certainly are easier ways to do this. The "use <something>" is including the module <something>.pm in the code, so it's subs/methods etc can be used by the program. On Thu, Jun 15, 2023 at 2:29 PM Freek de Kruijf <f.de.kru...@gmail.com> wrote: > Hi, > > I am trying to understand fully a perl program with the following lines: > > } elsif( /^(\#?\s*(?:pickup|qmgr)\s+)(?:fifo|unix)(\s+.*)/ ) { > if( defined $normalize->{$1} ) { next; } else { $normalize->{$1} = > 1; } > I do understand the first line, but I can not find what the second line is > about. > > As far as can see the tested line in $_, from a file, is all ASCII with > lower > case characters. At the begin of the perl program the is no "use > <something>". > > -- > > fr.gr. > > Freek de Kruijf > > > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- a Andy Bach, afb...@gmail.com 608 658-1890 cell 608 261-5738 wk