In the following Perl example, a regular expression is used, i.e., next unless s/^(.*?):\s*//; But, how to understand this regular expression, s/^(.*?):\s*//
while ( <> ) {
next unless s/^(.*?):\s*//;
$HoA{$1} = [ split ];
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It captures (and stores as
$1) some text up to a:. Then it removes the captured text, the semicolon and any trailing whitespace.Beyond the regex: if the regex succeeded in doing its job, then the code uses the captured text as a hash key whose value is an array reference. The elements of that array are the rest of the line split on whitespace.
gives