Search code examples
perlsubstr

Right truncate of attribute to string of length 40 in perl


I want to right truncate a value of attribute to string of length 40 using regex in Perl.

I tried to do it without using regex, only substr() but it’s not working.

$attribute = substr ($attribute , -1 ,40);

Solution

  • "Right truncate" equals to using substr() the usual way:

    $attribute = substr($attribute,0,40)