Re: how to extract the last digit

2008-04-03 Thread Jenda Krynicky
From: "Chas. Owens" <[EMAIL PROTECTED]> > 2008/4/3 Jay Savage <[EMAIL PROTECTED]>: > snip > > Exactly. The functionality is there to be taken advantage of. I don't > > see why that is "unfortunate" at all. How is "Mongolian digit three" > > less of a digit than arabic numeral three? That \d is u

Re: how to extract the last digit

2008-04-03 Thread Chas. Owens
2008/4/3 Jay Savage <[EMAIL PROTECTED]>: snip > Exactly. The functionality is there to be taken advantage of. I don't > see why that is "unfortunate" at all. How is "Mongolian digit three" > less of a digit than arabic numeral three? That \d is unicode-aware > is, IMO, it's strongest selling po

Re: how to extract the last digit

2008-04-03 Thread Jay Savage
On Tue, Apr 1, 2008 at 5:40 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > 2008/4/1 Jay Savage <[EMAIL PROTECTED]>: > snip > > > my ($last) = $number =~ /.*(\d)/; > > > > Let Perl worry about what is and isn't a digit. > snip > > Unfortunately, with the rise of UNICODE, \d is no longer what

Re: how to extract the last digit

2008-04-02 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > Thanks everyone for the help! > I get an error on 'chop' when I use the following. Why is this so? > Thanks > > use strict; > use warnings; > my @eightdecks = 1..20; > my $last = chop ($eightdecks[0] + $eightdecks[2]); > > if ($last =~ /[0-5]/){ > print "yes match

RE: how to extract the last digit

2008-04-02 Thread Jenda Krynicky
From: "sanket vaidya" <[EMAIL PROTECTED]> > You get the error on chop because anything given with chop function is > considered as string (In other words chop acts on string). So perl considers > the '+' operator you provide with chop as string rather than addition > operator.This is how your task

Re: how to extract the last digit

2008-04-02 Thread Jenda Krynicky
From: <[EMAIL PROTECTED]> > Thanks everyone for the help! > I get an error on 'chop' when I use the following. Why is this so? > Thanks > > use strict; > use warnings; > my @eightdecks = 1..20; > my $last = chop ($eightdecks[0] + $eightdecks[2]); Because chop() attempts to modif

RE: how to extract the last digit

2008-04-02 Thread sanket vaidya
Subject: Re: how to extract the last digit Thanks everyone for the help! I get an error on 'chop' when I use the following. Why is this so? Thanks use strict; use warnings; my @eightdecks = 1..20; my $last = chop ($eightdecks[0] + $eightdecks[2]); if ($last =~ /[0-5]/){ print &q

Re: how to extract the last digit

2008-04-02 Thread itshardtogetone
e{print "not match\n"}; - Original Message - From: "John W. Krahn" <[EMAIL PROTECTED]> To: "Perl Beginners" Sent: Wednesday, April 02, 2008 12:06 AM Subject: Re: how to extract the last digit [EMAIL PROTECTED] wrote: Hi, Hello, How do I extract the last digi

Re: how to extract the last digit

2008-04-01 Thread Chas. Owens
On Tue, Apr 1, 2008 at 5:17 PM, yitzle <[EMAIL PROTECTED]> wrote: > On Tue, Apr 1, 2008 at 4:03 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > > yitzle wrote: > > > Is there some way to convert it (a string/scalar) to an array? > > > > Is this what you mean? > > > > my $string = 'ABCDEF'; > >

Re: how to extract the last digit

2008-04-01 Thread Chas. Owens
2008/4/1 Jay Savage <[EMAIL PROTECTED]>: snip > my ($last) = $number =~ /.*(\d)/; > > Let Perl worry about what is and isn't a digit. snip Unfortunately, with the rise of UNICODE, \d is no longer what one expects* ([0-9]). It now includes all characters marked as digits in UNICODE. This inc

Re: how to extract the last digit

2008-04-01 Thread yitzle
On Tue, Apr 1, 2008 at 4:03 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > yitzle wrote: > > Is there some way to convert it (a string/scalar) to an array? > > Is this what you mean? > > my $string = 'ABCDEF'; > my @string = split '', $string; > > > > Rob I suppose. That can be used to extract th

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
yitzle wrote: > Is there some way to convert it (a string/scalar) to an array? Is this what you mean? my $string = 'ABCDEF'; my @string = split '', $string; Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to extract the last digit

2008-04-01 Thread yitzle
Is there some way to convert it (a string/scalar) to an array? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to extract the last digit

2008-04-01 Thread Jay Savage
On Tue, Apr 1, 2008 at 11:09 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: [snip] > > my ($lastdigit) = $number =~ /.*([0-9])/; > > gives you the last decimal digit (even if there are non-decimals after > it). > Better yet: my ($last) = $number =~ /.*(\d)/; Let Perl worry about what is and

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
John W. Krahn wrote: > [EMAIL PROTECTED] wrote: >> Hi, > > Hello, > >> How do I extract the last digit of a number? example I only want the digit 9 >> from the number 19. >> >> my $number = 19; > > my $last_digit = chop $number; Yes, although it's important to note that that method removes the

Re: how to extract the last digit

2008-04-01 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, How do I extract the last digit of a number? example I only want the digit 9 from the number 19. my $number = 19; my $last_digit = chop $number; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > How do I extract the last digit of a number? example I only want the digit 9 from the number 19. > > my $number = 19; There are a few ways. my $lastdigit = substr $number, -1; gives you the last character in the string my $lastdigit = $number % 10; gives you t

how to extract the last digit

2008-04-01 Thread itshardtogetone
Hi, How do I extract the last digit of a number? example I only want the digit 9 from the number 19. my $number = 19;