in reply to Re^2: Read the values from a file
in thread Read the values from a file

Can you please explain the following code (3 Lines)
next unless /^\[$brand\]$/ .. !/\S/;

This uses the "flip-flop" operator (i.e. '..' in a scalar context) to only process the lines that we are interested in. The flip-flop operator returns false until its left operand is true. It then continues to return true until its right hand operator is true. At that point it returns false and continues to do so until its left hand operand is true again. And so on.

So here we us "next" to skip to the next loop iteration unless we are between the [XXX] line that starts our required section and the blank line that ends it.

next if /^\[/;

We don't actually need to process the [XXX], so this code skips to the next loop iteration.

next unless /\S/;

And similarly for the blank line that ends the section.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg