Basically I have some very long variables and need only the first few characters.
I tried using this regex, but it doesn’t work.
$var =~ s/(^.{20})?/$1/g;
It doesn’t do anything to it.
Any help would be appreciated.
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.
Note that the simpler:
will croak if the string is less than 20 characters.
Or using substitution (assuming 5.10+):
Or using unpack: