Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 202010
 

Remove the last character of a string in Perl

Answer:

If you want to remove the last character of a string in Perl, e.g.

abc => ab

You can use the chop() function.

my $string = 'abc';
chop($string);
print $string; # give ab

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>