Re: Easy One

2006-05-03 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 $c), the

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-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 warnings

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 snip: Bill's email my ($b, $c) = ($1, $2) if $a =~ /^(\D+)(\d+)/; Don't do

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 construct all

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 $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 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-02 Thread Timothy Johnson
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 o. On Mon, 1 May 2006

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 snip if (length $string == 8) # might as well check eh? { $string =~

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 believe

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 snip if (length $string == 8) # might as well check eh? { $string =~

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+)$/; print \$1 $1 \$2 $2\n;

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: snip: output that proves me wrong 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

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 arguments sake, that contains

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 the

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 snip: snippiness The original problem stated that the string will have different

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 exactly. My

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-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 to contain

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 string

RE: Easy One

2006-05-01 Thread Timothy Johnson
How about something like this? #Check the length unless(length($myScalar) != 8){ die(Bad Scalar! Bad!\n); } #Get the parts if($myScalar =~ /^([^0-9]*)(\d+.*)$/ ){ print $1 $2\n; } NOTE: NEVER name your variable $a. $a

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, I have

RE: Easy One

2006-05-01 Thread Leigh Sharpe
This appears to work: use strict; use warnings; my @input=(abcd1234,abc12345,abcde123); foreach my $sample(@input) { print $sample:\n; $sample=~m/([a-zA-Z]*)([0-9]*)/; my $letters=$1; my $numbers=$2; print Letters $letters\tNumbers $numbers\n; } Regards,

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 have a string, $a for arguments sake, that contains

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? { $string