Re: Easy One

2006-05-03 Thread Chris Wagner
At 06:12 PM 5/3/2006 -0700, $Bill Luebkert wrote: >Having said that, I would also say that $a and $b were a bad choice for >the sorting vrbls. Let's hope something more intuitive (special looking) >for Perl 6 - like a separate namespace/syntax for special vrbls (like >maybe $^a, $^b or some such).

Re: Easy One

2006-05-03 Thread $Bill Luebkert
Timothy Johnson wrote: >>my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; > > > Don't do that! $a and $b are special variables used by perl for sorting > (and even if they weren't it would be bad form to use variables whose > names have no bearing on their contents). While $a and $b are special,

RE: Easy One

2006-05-03 Thread Chris Wagner
At 09:34 AM 5/3/2006 -0700, Timothy Johnson wrote: >Don't do that! $a and $b are special variables used by perl for sorting >(and even if they weren't it would be bad form to use variables whose >names have no bearing on their contents). Nah, they're not that special. $a and $b are only special

Re: Easy One

2006-05-03 Thread John Deighan
At 11:07 AM 5/3/2006, David Kaufman wrote: Hi Chris, Chris Wagner <[EMAIL PROTECTED]> wrote: > At 01:28 AM 5/3/2006 -0400, David Kaufman wrote: >> my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; > > U can't combine a my and an if. Perl will go schizo. Sure "U" can :-) I use this type of constru

RE: Easy One

2006-05-03 Thread Timothy Johnson
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Kaufman Sent: Tuesday, May 02, 2006 10:29 PM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Easy One > my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; Don't do that! $a an

Re: Easy One

2006-05-03 Thread David Kaufman
Hi Chris, Chris Wagner <[EMAIL PROTECTED]> wrote: > At 01:28 AM 5/3/2006 -0400, David Kaufman wrote: >> my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; > > U can't combine a my and an if. Perl will go schizo. Sure "U" can :-) I use this type of construct all the time, even with strict mode and

Re: Easy One

2006-05-03 Thread Chris Wagner
At 01:28 AM 5/3/2006 -0400, David Kaufman wrote: >my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; U can't combine a my and an if. Perl will go schizo. -- REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=-- "...ne cede malis" 0100 ___

Re: Easy One

2006-05-02 Thread David Kaufman
Hi Bill (in Brooklyn), Ng, Bill <[EMAIL PROTECTED]> wrote: > Real simple, > > I have a string, "$a" for arguments sake, that contains a single > word. The word will always have exactly 8 characters in it, most > likely something like "ABCD1234". I need to split this up into two > strings ($b &

Re: Easy One

2006-05-02 Thread $Bill Luebkert
Timothy Johnson wrote: > if ($str =~ /^(?=.{8}$)(\D+)(\d+)$/){ I like it - solves both problems. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Easy One

2006-05-02 Thread $Bill Luebkert
$Bill Luebkert wrote: > Luke Bakken wrote: > > > What is the purpose of this illustration in the context of the > >>original stated problem? The original problem stated that the string >>will have different numbers of alphabetic characters and numbers while >>your regex specifies 4 digits exact

RE: Easy One

2006-05-02 Thread Timothy Johnson
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of $Bill Luebkert Sent: Tuesday, May 02, 2006 5:42 PM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Easy One >> The original problem stated that the string >> will have differen

Re: Easy One

2006-05-02 Thread $Bill Luebkert
Luke Bakken wrote: > What is the purpose of this illustration in the context of the > original stated problem? The original problem stated that the string > will have different numbers of alphabetic characters and numbers while > your regex specifies 4 digits exactly. My code was in reference to

RE: Easy One

2006-05-02 Thread Timothy Johnson
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luke Bakken Sent: Tuesday, May 02, 2006 6:16 AM To: Timothy Johnson Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: Easy One >> >> I have a string, "$a" for argumen

Re: Easy One

2006-05-02 Thread Luke Bakken
>Maybe you're used to some old behavior in Perl, but that doesn't >appear to be the case in 5.8.8 at least. I get this output: Ah. Okay, I see why that worked now. $1, $2 et al are scoped to the current block, so in this case you are right. If you were to do two pattern matches within the

RE: Easy One

2006-05-02 Thread Suresh Govindachar
[resending with a better counter-example] Luke Bakken wrote: >>> use strict; >>> >>> my $str = ''; >>> matchit(); >>> $str = ''; >>> matchit(); >>> >>> sub matchit >>> { >>> if (length $str == 8) { >>> $str =~ /^(\D+)(\d+)$/; >>>

RE: Easy One

2006-05-02 Thread Suresh Govindachar
Luke Bakken wrote: >>> use strict; >>> >>> my $str = ''; >>> matchit(); >>> $str = ''; >>> matchit(); >>> >>> sub matchit >>> { >>> if (length $str == 8) { >>> $str =~ /^(\D+)(\d+)$/; >>> print "\$1 $1 \$2 $2\n"; >>>

Re: Easy One

2006-05-02 Thread Luke Bakken
I have a string, "$a" for arguments sake, that contains a >> >>single >> word. The word will always have exactly 8 characters in it, most >> >>likely >> something like "ABCD1234". I need to split this up into two strings >> >>($b >> >> >> >>>if (length $string == 8) # might a

Re: Easy One

2006-05-02 Thread $Bill Luebkert
Luke Bakken wrote: I have a string, "$a" for arguments sake, that contains a >> >>single >> word. The word will always have exactly 8 characters in it, most >> >>likely >> something like "ABCD1234". I need to split this up into two strings >> >>($b >> >> >> >>>if (length $str

RE: Easy One

2006-05-02 Thread Nelson R. Pardee
Ah, you made me go back and reread the manual on this. It does sound like it doesn't matter if there's no variable to interpolate. Although- when I recently did some timing, it seemed to make a very slight difference. On Tue, 2 May 2006, Timothy Johnson wrote: > Why did you add the "o"? I believ

Re: Easy One

2006-05-02 Thread Luke Bakken
>> I have a string, "$a" for arguments sake, that contains a single >> word. The word will always have exactly 8 characters in it, most likely >> something like "ABCD1234". I need to split this up into two strings ($b > >if (length $string == 8) # might as well check eh? >{ >$stri

RE: Easy One

2006-05-02 Thread Timothy Johnson
f Nelson R. Pardee Sent: Monday, May 01, 2006 7:37 PM To: Ng, Bill; Active State Perl Subject: Re: Easy One Is there a reason you don't write it my ($characterString, $numberString) = $string =~ /^([^\d]+)(.*)$/o; This will assure the values are not defined if the regex fails. I also added &quo

Re: Easy One

2006-05-01 Thread Nelson R. Pardee
Is there a reason you don't write it my ($characterString, $numberString) = $string =~ /^([^\d]+)(.*)$/o; This will assure the values are not defined if the regex fails. I also added "o". On Mon, 1 May 2006, Luke Bakken wrote: > if (length $string == 8) # might as well check eh? > { > $st

RE: Easy One

2006-05-01 Thread John Serink
REGEX! > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Ng, Bill > Sent: Tuesday, May 02, 2006 3:55 AM > To: perl-win32-users@listserv.ActiveState.com > Subject: Easy One > > > Real simple, > > I ha

RE: Easy One

2006-05-01 Thread Leigh Sharpe
Tuesday, May 02, 2006 5:55 AM To: perl-win32-users@listserv.ActiveState.com Subject: Easy One Real simple, I have a string, "$a" for arguments sake, that contains a single word. The word will always have exactly 8 characters in it, most likely something like "ABCD1234

RE: Easy One

2006-05-01 Thread Timothy Johnson
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luke Bakken Sent: Monday, May 01, 2006 2:50 PM To: Ng, Bill Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: Easy One On 5/1/06, Ng, Bill <[EMAIL PROTECTED]> wrote: >> Real simple, >

Re: Easy One

2006-05-01 Thread Luke Bakken
On 5/1/06, Ng, Bill <[EMAIL PROTECTED]> wrote: Real simple, I have a string, "$a" for arguments sake, that contains a single word. The word will always have exactly 8 characters in it, most likely something like "ABCD1234". I need to split this up into two strings ($b & $c), the first

RE: Easy One

2006-05-01 Thread Timothy Johnson
ame your variable $a. $a and $b are special variables used in sorting. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ng, Bill Sent: Monday, May 01, 2006 12:55 PM To: perl-win32-users@listserv.ActiveState.com Subject: Easy One Real simple, I hav

RE: Easy One

2006-05-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote: > Real simple, > > I have a string, "$a" for arguments sake, that contains a single > word. The word will always have exactly 8 characters in it, most > likely something like "ABCD1234". I need to split this up into two > strings ($b & $c), the first string needs t

Easy One

2006-05-01 Thread Ng, Bill
Real simple, I have a string, "$a" for arguments sake, that contains a single word. The word will always have exactly 8 characters in it, most likely something like "ABCD1234". I need to split this up into two strings ($b & $c), the first string needs to contain all the characters before