--- On Tue, 24/11/09, Shawn H Corey <[email protected]> wrote:
> From: Shawn H Corey <[email protected]> > Subject: Re: 答复: Regex to get last 3 digits of a number. > To: "gaochong" <[email protected]> > Cc: "'John W. Krahn'" <[email protected]>, "'Perl Beginners'" > <[email protected]> > Received: Tuesday, 24 November, 2009, 8:26 PM > gaochong wrote: > > But I think substr is better . > > > > my $str="0000000000000111"; > > my $r=substr ($str,-3); > > TimTowTdi (there is more than one way to do it): > > my $n = "0000000000000111"; > my $last_3_chars = join('',(split(//,$n))[-3..-1]); The worst way, :-) split is much slower than others. __________________________________________________________________________________ Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7. Enter now: http://au.docs.yahoo.com/homepageset/ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
