in reply to How do I capture the last character in a string?

There are many ways to get the last character from a string :

use strict; my $string = "Hello World"; my $char; # Use a capturing parenthesis $char = $1 if ($string =~ /(.)\Z/); print ">>$string<<\n"; print "[[$char]]"; # Chop the last char away from $string # this modifies $string $char = chop $string; print ">>$string<<\n"; print "[[$char]]"; # use substr : $char = substr($string,-1); print ">>$string<<\n"; print "[[$char]]";

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web