simple question on perl

Jay Pike jay.pike@voyager.net
Fri, 1 Sep 2000 15:00:40 -0400


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/;

jp

Adam McDougall wrote:
> chop or chomp?
> 
> On Fri, 1 Sep 2000, Daniel R . Kilbourne wrote:
> 
> > Call me a perl idiot, but how do I remove the last character from a string?
> > 
> > I will need to pull the last character from a line such as:
> > 
> > 3.3219333333e+02  (I need to get the 2 in this case)
> > 
> > the string will always be of constant length.
> > 
> > Anyone?
> > 
> > ___
> > Dan
> > _______________________________________________
> > linux-user mailing list
> > linux-user@egr.msu.edu
> > http://www.egr.msu.edu/mailman/listinfo/linux-user
> > 
> 
> _______________________________________________
> linux-user mailing list
> linux-user@egr.msu.edu
> http://www.egr.msu.edu/mailman/listinfo/linux-user

-- 
   __________________________________________________________________________
 /                                                                            \
|       James J. Pike Jr.         Phone: 888.747.4638                          |
|       Network Engineer          Direct Phone: 517-324-5890                   |
|       Voyager.Net Inc.          Http: http://www.voyager.net/                |
| EMail: jay.pike@voyager.net PGPKey: http://my.voyager.net/jaypike/pgpkey.txt |
 \                                                                            /
   --------------------------------------------------------------------------