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 (/-------/);
}
/\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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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