$value = $list[1] ~ s/\D//g;
syntax error at try1.pl line 53, near “] ~”
Execution of try1.pl aborted due to compilation errors.
I am trying to extract the digits from the second element of @list, and store it into $value.
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.
You mean =~, not ~. ~ is a unary bitwise negation operator.
A couple of ways to do this:
Both sets of parens are important; only if there are capturing parentheses does the match operation return actual content instead of just an indication of success, and then only in list context (provided by the list-assign operator
()=).Or the common idiom of copy and then modify: