simple question on perl

Dpk dpk@egr.msu.edu
Fri, 1 Sep 2000 15:06:10 -0400


On Fri, Sep 01, 2000 at 03:00:40PM -0400, Jay Pike wrote:

   chop() or chomp() removes the last character, but I don't think you GET
   just that last character.
   
   I like regexs, so I was thinking something like:
   
   $variable =~ s/.*(.)$/$1/;
   
Yes, the character removed is the return value:

$char = chop($variable);

[dpk@chavez:~] perl -e '$test = "test"; $char = chop($test); print "$char\n";'
t

dpk