Link to home
Start Free TrialLog in
Avatar of biggin777
biggin777

asked on

REGEX question

What does this regex do.

/\S/ && !/\S/

Someone gave me the answer to help my script (And it did), I would just like to know what it is doing.

foreach (@textData) {
        $_ .= "\n" if $prev=~/\S/ && !/\S/;
        $prev = '';
        $prev = chomp if /\S/;
       
        print CONFIG $prev = $_
          unless (/-------/);
         
}
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

foreach (@textData) { # loading all lines line after line , line=$_
        $_ .= "\n" if $prev=~/\S/ && !/\S/; # NEVER adding \n (EOL)
        $prev = '';
        $prev = chomp if /\S/;
       
        print CONFIG $prev = $_
          unless (/-------/);
         
}

regular lines are concatenate to each other ,
empty line provide new line

tal