Re: REGEX help!

2004-01-13 Thread Mike Jackson
I think this is why $Bill said use the syscall rather than the RE - IPs are also legally expressed as the raw 32 bit number in decimal, or as a subset of the dotted quad only including the elements required to dis-ambiguate depending on the subnet mask (with a subnet mask of 255.0.0.0, 127. is a valid IP representing the network (or is it broadcast?) address...)

not following standards will always bite you in the behind at some stage.. :)

On Tue, 13 Jan 2004 20:18:58 -0800, Glenn Linderman <[EMAIL PROTECTED]> wrote:

On approximately 1/13/2004 7:01 PM, came the following characters from
the keyboard of Jamie Murray:
Hi Glenn,
I have worked on this further and looked at some of the previous posts.
I have tried this with all different combinations of ip address and this has
worked.
Of course I got the idea from a previous post from Alex and Mark Thomas.
Please understand I could have just copied and pasted Mark's solution but
then I wouldn't have learned anything.
if($num =~ /^(([0-1]{0,1}[0-9]{0,1}[0-9]|2[0-4][0-9]|25[0-5])\.?){4}$/)
Well, this REGEX appears like it will match all the desired cases. However, the optional \. and the {4} combine to allow it to successfully match some things that you might not want to match.  Mark's post is better, but let us learn why.

I've mentioned this as a difference before, but the use of \d instead of [0-9]  and  ?  instead of {0,1} both tend to aid readability, because they are shorter, so the specific concept that they represent, while in one sense "just a shorthand" for exactly the way you express it, becomes more readable to the people that understand those shortcuts, because it takes less reading and thought to grasp the concept.  When you see [0-9], all 5 characters have to be examined to realize that the expression means "a numeric character", whereas \d requires only the examination of 2 characters to arrive at the same conclusion.  Similarly for ? vs {0,1}.  These shortcuts can save time in reading the expression, and also stand out as different from [0-4]  and {0,4}, and are for very common cases where the benefits of knowing and understanding the shortcuts help significantly in quickly understanding the REGEX.

Now the \.?){4} vs spelling out 4 instances.  I really don't know anything about the edge cases that people talk about that have fewer than 3 dots, and/or more than 3 digit groupings of numbers all the IP addresses I have ever seen have been so called "dotted quads".  I'm sure there is an RFC somewhere that describes the exact details of what is and is not legal IP address notation.  Clearly, an IP address is "just a 32-bit number" and can be expressed in a number of ways other than the "dotted quad".  However, the Cookbook expression that Alex started with was clearly intended to match "dotted quads" and only "dotted quads", and so I think is the goal you are trying to achieve.

Your REGEX allows fewer than 3 dots.  The \.? is optional in each of the 4 groupings, not only for the last one.  So your REGEX would permit things that aren't "dotted quads", such as

127.999

1.2.34
123234135157
When testing software of any sort, it is important to be sure that it accepts the things you want to accept, and also rejects the things it doesn't understand.

I feel that Mark's post is the better choice though and much
slicker than mine.
my $octet = qr/\d|[01]?\d\d|2[0-4]\d|25[0-5]/;
my $valid_ip = qr/^$octet\.$octet\.$octet\.$octet$/o;
print "yes" if $ip =~ $valid_ip;
Yes, Mark's solution is better than yours, in that it only accepts dotted quads, and it is better than the Cookbook solution (in my opinion) because it removes the complex redundancy, and can be expressed   in half the lines even with the enhanced clarity.

Happy learning.


- Original Message - From: "Glenn Linderman" <[EMAIL PROTECTED]>
To: "Jamie Murray" <[EMAIL PROTECTED]>
Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 6:24 PM
Subject: Re: REGEX help!


On approximately 1/13/2004 6:49 AM, came the following characters from
the keyboard of Jamie Murray:
Hi guys,
I have seen my error which I have overlooked and don't mind admitting
it.

: )  Course don't hold it against me cause I'm just eager to learn
and try things out.
My regex works it matches exactly what I want but not all possibilities
.

I overlooked the simple fact that alex wants not 0 or 2 or 5 or 4 but
254

or less.
Course with the example I posted Alex can easily adjust for this.
So my method excludes 65 and up ,165 and up but not 254 to 200 or 154 to
100

or 54 or less.
So yes Bill im excluding 192 amongst others in my regex I see your
point.

Ok so this gets a little deeper than expected because I can have 199 but
not

299

/^([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9]
|

2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] |
25[0-5])\.

([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5]) $/

so now we are checking for 000

Re: REGEX help!

2004-01-13 Thread Jamie Murray
Thanks for the discussion,clear explanation and advice Glenn.


- Original Message - 
From: "Glenn Linderman" <[EMAIL PROTECTED]>
To: "Jamie Murray" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 14, 2004 12:48 AM
Subject: Re: REGEX help!


> On approximately 1/13/2004 7:01 PM, came the following characters from
> the keyboard of Jamie Murray:
> > Hi Glenn,
> > I have worked on this further and looked at some of the previous posts.
> > I have tried this with all different combinations of ip address and this
has
> > worked.
> > Of course I got the idea from a previous post from Alex and Mark Thomas.
> > Please understand I could have just copied and pasted Mark's solution
but
> > then I wouldn't have learned anything.
> >
> > if($num =~ /^(([0-1]{0,1}[0-9]{0,1}[0-9]|2[0-4][0-9]|25[0-5])\.?){4}$/)
>
> Well, this REGEX appears like it will match all the desired cases.
> However, the optional \. and the {4} combine to allow it to successfully
> match some things that you might not want to match.  Mark's post is
> better, but let us learn why.
>
> I've mentioned this as a difference before, but the use of \d instead of
> [0-9]  and  ?  instead of {0,1} both tend to aid readability, because
> they are shorter, so the specific concept that they represent, while in
> one sense "just a shorthand" for exactly the way you express it, becomes
> more readable to the people that understand those shortcuts, because it
> takes less reading and thought to grasp the concept.  When you see
> [0-9], all 5 characters have to be examined to realize that the
> expression means "a numeric character", whereas \d requires only the
> examination of 2 characters to arrive at the same conclusion.  Similarly
> for ? vs {0,1}.  These shortcuts can save time in reading the
> expression, and also stand out as different from [0-4]  and {0,4}, and
> are for very common cases where the benefits of knowing and
> understanding the shortcuts help significantly in quickly understanding
> the REGEX.
>
> Now the \.?){4} vs spelling out 4 instances.  I really don't know
> anything about the edge cases that people talk about that have fewer
> than 3 dots, and/or more than 3 digit groupings of numbers all the
> IP addresses I have ever seen have been so called "dotted quads".  I'm
> sure there is an RFC somewhere that describes the exact details of what
> is and is not legal IP address notation.  Clearly, an IP address is
> "just a 32-bit number" and can be expressed in a number of ways other
> than the "dotted quad".  However, the Cookbook expression that Alex
> started with was clearly intended to match "dotted quads" and only
> "dotted quads", and so I think is the goal you are trying to achieve.
>
> Your REGEX allows fewer than 3 dots.  The \.? is optional in each of the
> 4 groupings, not only for the last one.  So your REGEX would permit
> things that aren't "dotted quads", such as
>
> 127.999
> 
> 1.2.34
> 123234135157
>
> When testing software of any sort, it is important to be sure that it
> accepts the things you want to accept, and also rejects the things it
> doesn't understand.
>
> > I feel that Mark's post is the better choice though and much
> > slicker than mine.
> >
> > my $octet = qr/\d|[01]?\d\d|2[0-4]\d|25[0-5]/;
> > my $valid_ip = qr/^$octet\.$octet\.$octet\.$octet$/o;
> >
> > print "yes" if $ip =~ $valid_ip;
>
> Yes, Mark's solution is better than yours, in that it only accepts
> dotted quads, and it is better than the Cookbook solution (in my
> opinion) because it removes the complex redundancy, and can be expressed
>   in half the lines even with the enhanced clarity.
>
> Happy learning.
>
>
> > - Original Message - 
> > From: "Glenn Linderman" <[EMAIL PROTECTED]>
> > To: "Jamie Murray" <[EMAIL PROTECTED]>
> > Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>;
> > <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 13, 2004 6:24 PM
> > Subject: Re: REGEX help!
> >
> >
> >
> >>On approximately 1/13/2004 6:49 AM, came the following characters from
> >>the keyboard of Jamie Murray:
> >>
> >>>Hi guys,
> >>> I have seen my error which I have overlooked and don't mind admitting
> >
> > it.
> >
> >>>: )  Course don't hold it against me cause I'm just eager to learn
> >>>and try things out.
> >>>My regex works it matches exactly what I want but not all possibilities
> >
> > .
> >
> >>> I overlooked the simple fact that alex wants not 0 or 2 or 5 or 4 but
> >
> > 254
> >
> >>>or less.
> >>>Course with the example I posted Alex can easily adjust for this.
> >>>
> >>>So my method excludes 65 and up ,165 and up but not 254 to 200 or 154
to
> >
> > 100
> >
> >>>or 54 or less.
> >>>So yes Bill im excluding 192 amongst others in my regex I see your
> >
> > point.
> >
> >>>Ok so this gets a little deeper than expected because I can have 199
but
> >
> > not
> >
> >>>299
> >>>
> >>>/^([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\.
([0-1]{0,1}[0-9][0-9]
> >
> > |
> >
> >>>2[0-4][0-9] | 25[0-5])\. 

Re: REGEX help!

2004-01-13 Thread Glenn Linderman
On approximately 1/13/2004 7:01 PM, came the following characters from
the keyboard of Jamie Murray:
Hi Glenn,
I have worked on this further and looked at some of the previous posts.
I have tried this with all different combinations of ip address and this has
worked.
Of course I got the idea from a previous post from Alex and Mark Thomas.
Please understand I could have just copied and pasted Mark's solution but
then I wouldn't have learned anything.
if($num =~ /^(([0-1]{0,1}[0-9]{0,1}[0-9]|2[0-4][0-9]|25[0-5])\.?){4}$/)
Well, this REGEX appears like it will match all the desired cases. 
However, the optional \. and the {4} combine to allow it to successfully 
match some things that you might not want to match.  Mark's post is 
better, but let us learn why.

I've mentioned this as a difference before, but the use of \d instead of 
[0-9]  and  ?  instead of {0,1} both tend to aid readability, because 
they are shorter, so the specific concept that they represent, while in 
one sense "just a shorthand" for exactly the way you express it, becomes 
more readable to the people that understand those shortcuts, because it 
takes less reading and thought to grasp the concept.  When you see 
[0-9], all 5 characters have to be examined to realize that the 
expression means "a numeric character", whereas \d requires only the 
examination of 2 characters to arrive at the same conclusion.  Similarly 
for ? vs {0,1}.  These shortcuts can save time in reading the 
expression, and also stand out as different from [0-4]  and {0,4}, and 
are for very common cases where the benefits of knowing and 
understanding the shortcuts help significantly in quickly understanding 
the REGEX.

Now the \.?){4} vs spelling out 4 instances.  I really don't know 
anything about the edge cases that people talk about that have fewer 
than 3 dots, and/or more than 3 digit groupings of numbers all the 
IP addresses I have ever seen have been so called "dotted quads".  I'm 
sure there is an RFC somewhere that describes the exact details of what 
is and is not legal IP address notation.  Clearly, an IP address is 
"just a 32-bit number" and can be expressed in a number of ways other 
than the "dotted quad".  However, the Cookbook expression that Alex 
started with was clearly intended to match "dotted quads" and only 
"dotted quads", and so I think is the goal you are trying to achieve.

Your REGEX allows fewer than 3 dots.  The \.? is optional in each of the 
4 groupings, not only for the last one.  So your REGEX would permit 
things that aren't "dotted quads", such as

   127.999
   
   1.2.34
   123234135157
When testing software of any sort, it is important to be sure that it 
accepts the things you want to accept, and also rejects the things it 
doesn't understand.

I feel that Mark's post is the better choice though and much
slicker than mine.
my $octet = qr/\d|[01]?\d\d|2[0-4]\d|25[0-5]/;
my $valid_ip = qr/^$octet\.$octet\.$octet\.$octet$/o;
print "yes" if $ip =~ $valid_ip;
Yes, Mark's solution is better than yours, in that it only accepts 
dotted quads, and it is better than the Cookbook solution (in my 
opinion) because it removes the complex redundancy, and can be expressed 
 in half the lines even with the enhanced clarity.

Happy learning.


- Original Message - 
From: "Glenn Linderman" <[EMAIL PROTECTED]>
To: "Jamie Murray" <[EMAIL PROTECTED]>
Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 6:24 PM
Subject: Re: REGEX help!



On approximately 1/13/2004 6:49 AM, came the following characters from
the keyboard of Jamie Murray:
Hi guys,
I have seen my error which I have overlooked and don't mind admitting
it.

: )  Course don't hold it against me cause I'm just eager to learn
and try things out.
My regex works it matches exactly what I want but not all possibilities
.

I overlooked the simple fact that alex wants not 0 or 2 or 5 or 4 but
254

or less.
Course with the example I posted Alex can easily adjust for this.
So my method excludes 65 and up ,165 and up but not 254 to 200 or 154 to
100

or 54 or less.
So yes Bill im excluding 192 amongst others in my regex I see your
point.

Ok so this gets a little deeper than expected because I can have 199 but
not

299

/^([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9]
|

2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] |
25[0-5])\.

([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5]) $/

so now we are checking for 000 or 00 to 199 or 200 to 249 or 250 to 255
followed by \.
Now I should have this right. Making mistakes sure helps you learn and
think things through more thoroughly.
How is that or do you have anymore suggestions.
As someone else pointed out, you are rapidly approaching the REGEX given
in the Perl Cookbook.  Once you add a case to handle single digit
numbers you will be there.
The only other differences are that you are using {0,1} which is exactly
the same as ?, and you are using [0-9] whic

Re: Press any key to exit

2004-01-13 Thread Yeoh Yiu
"Aaron.Tesch" <[EMAIL PROTECTED]> writes:

> This will work for all of your Standard Keyboard keys.  (does not
> include Funcion keys.

What about ESC or shift ?


> 
> use Term::ReadKey;  END { ReadMode ('restore'); }
> $|=1;
> my $char = "";
> print "Press Any Key to Continue:";
> # character method
> binmode STDIN;
> ReadMode ('cbreak');
> while  (not defined (my $ch = ReadKey ())) 
> {
>   ## Nothing to do but wait.
> }
> ReadMode ('restore');
> $| = 0; # unbuffer stdout
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: In your opinion, what's a good second languange to learn?

2004-01-13 Thread Mike Jackson
Once you've learned a few fairly different languages, you start to disassociate your method from the language at hand, and start to merely use it as a further layer of abstraction (which is what programming is all about), with the effect that you can use just about any language to do what you want - so long as the language has the capability available.

I've done vb to mirc scripting to perl to risc assembler, pascal, some c and c#, a fair bit of javascript, css and html (which I kinda consider languages - they describe what you want the computer to do), logo, a touch of lisp...

I reckon I could learn java in under a week, same cobol or fortran - they will have common elements with most of the above languages, or form a basis for them...

its better to pick a project to do, _then_ decide on the best language to do it in!

quick utilities and small apps - vb
string processing, not much gui - perl!
decent and robust app - c
decent and robust app that uses objects - c#
webpages - js/html/css of course
robots - risc assembler/uC c/logo
irc bots/tools/utils - perl/mirc script
thats my general list of favourites...


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, January 13, 2004 11:41 AM
To: [EMAIL PROTECTED]
Subject: In your opinion, what's a good second languange to learn?
Hi All,

I need some advise from you out there who have more experience with
development.  The only language I know is Perl.  I have been using it for
more than two years now.  I had accomplished all tasks I needed to do at
work (as an IT Support person) quite easily.  I really like programming
and I'd like to be a software developer in the next coming years.  When I
look at the job market right now, companies are looking for developers who
know a lot of programming languages, Perl, Java, C, C++, VB, Python,
etc...  But I just have so little time to study all of these.  So in your
opinion, If I want to be bilingual and if I want to go into software
development, which second language would be best?
Regards,
Sam
___
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread Jamie Murray
Hi Glenn,
I have worked on this further and looked at some of the previous posts.
I have tried this with all different combinations of ip address and this has
worked.
Of course I got the idea from a previous post from Alex and Mark Thomas.
Please understand I could have just copied and pasted Mark's solution but
then I wouldn't have learned anything.

if($num =~ /^(([0-1]{0,1}[0-9]{0,1}[0-9]|2[0-4][0-9]|25[0-5])\.?){4}$/)

I feel that Mark's post is the better choice though and much
slicker than mine.

my $octet = qr/\d|[01]?\d\d|2[0-4]\d|25[0-5]/;
my $valid_ip = qr/^$octet\.$octet\.$octet\.$octet$/o;

print "yes" if $ip =~ $valid_ip;




- Original Message - 
From: "Glenn Linderman" <[EMAIL PROTECTED]>
To: "Jamie Murray" <[EMAIL PROTECTED]>
Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 6:24 PM
Subject: Re: REGEX help!


> On approximately 1/13/2004 6:49 AM, came the following characters from
> the keyboard of Jamie Murray:
> > Hi guys,
> >  I have seen my error which I have overlooked and don't mind admitting
it.
> > : )  Course don't hold it against me cause I'm just eager to learn
> > and try things out.
> > My regex works it matches exactly what I want but not all possibilities
.
> >  I overlooked the simple fact that alex wants not 0 or 2 or 5 or 4 but
254
> > or less.
> > Course with the example I posted Alex can easily adjust for this.
> >
> > So my method excludes 65 and up ,165 and up but not 254 to 200 or 154 to
100
> > or 54 or less.
> > So yes Bill im excluding 192 amongst others in my regex I see your
point.
> > Ok so this gets a little deeper than expected because I can have 199 but
not
> > 299
> >
> > /^([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9]
|
> > 2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] |
25[0-5])\.
> > ([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5]) $/
> >
> > so now we are checking for 000 or 00 to 199 or 200 to 249 or 250 to 255
> > followed by \.
> >  Now I should have this right. Making mistakes sure helps you learn and
> > think things through more thoroughly.
> >
> > How is that or do you have anymore suggestions.
>
> As someone else pointed out, you are rapidly approaching the REGEX given
> in the Perl Cookbook.  Once you add a case to handle single digit
> numbers you will be there.
>
> The only other differences are that you are using {0,1} which is exactly
> the same as ?, and you are using [0-9] which is exactly the same and \d.
>   In both cases, the latter of the two equivalent expressions is shorter
> to express, and used by the REGEX in the Perl Cookbook.
>
> >
> >
> > - Original Message - 
> > From: "Jamie Murray" <[EMAIL PROTECTED]>
> > To: "$Bill Luebkert" <[EMAIL PROTECTED]>;
> > <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 13, 2004 9:40 AM
> > Subject: Re: REGEX help!
> >
> >
> >
> >>BiLL,
> >>If you check my second post I made the correction but I'm still correct
in
> >>my example and method.
> >> Actually the e-mail from Raul Davletshin pretty much verifys what I had
> >>also stated and he's also correct.
> >>As for explaining [0-2]  0 or 1 or 2 are all possibilities of course but
> >>only one(unless using ? but thats another story)
> >> so wheres the problem your explaining something we already know.
> >>Also the example I gave Alex can be adjusted to his needs using class []
> >>and range {}. At least he will know how to put together
> >>some type of expression that works instead of just relying on built in
> >>functions.
> >>As for your post down below you can check numbers that way.
> >>Did you run this in a script before you decided it doesn't work because
it
> >>worked perfectly for me.
> >>Please run what I have below and correct what is "actually incorrect"
not
> >>what you "think is incorrect"
> >> I'm all for learning and am just trying my best.
> >>
> >>Thanks!
> >>
> >>
> >>- Original Message - 
> >>From: "$Bill Luebkert" <[EMAIL PROTECTED]>
> >>To: <[EMAIL PROTECTED]>
> >>Sent: Tuesday, January 13, 2004 5:07 AM
> >>Subject: Re: REGEX help!
> >>
> >>
> >>
> >>>Jamie Murray wrote:
> >>>
> >>>
> Hey Alex,
> I jumped a little quick there, the previous post does work but I had a
> >>
> >>doh
> >>
> moment and forgot your upper range match could only be 254 at most.
> Sorry about that.
> 
> if($num =~
> 
> >
> > /^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
> >
> >>> ^^^  ^^^  ^^^
> >>>The digits can be 0-9, not 0-2, 0-4 or 0-5.  eg: 192.168.0.1 is a legal
> >
> > IP
> >
> >>>You can't check a number range this way.
> >>>
> >>>
>  after each class [] use {num,num} to adjust for a part of the ip not
> >>
> >>having
> >>
> a number.
> 
> so for example
> 
> if($num =~
> 
> >>
> >
/^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
> >
> matches ip's like these
>  "three digit 254 or less"."three digit 254 or less"."three di

Re: REGEX help!

2004-01-13 Thread Glenn Linderman
On approximately 1/13/2004 6:49 AM, came the following characters from
the keyboard of Jamie Murray:
Hi guys,
 I have seen my error which I have overlooked and don't mind admitting it.
: )  Course don't hold it against me cause I'm just eager to learn
and try things out.
My regex works it matches exactly what I want but not all possibilities .
 I overlooked the simple fact that alex wants not 0 or 2 or 5 or 4 but 254
or less.
Course with the example I posted Alex can easily adjust for this.
So my method excludes 65 and up ,165 and up but not 254 to 200 or 154 to 100
or 54 or less.
So yes Bill im excluding 192 amongst others in my regex I see your point.
Ok so this gets a little deeper than expected because I can have 199 but not
299
/^([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9] |
2[0-4][0-9] | 25[0-5])\. ([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\.
([0-1]{0,1}[0-9][0-9] | 2[0-4][0-9] | 25[0-5]) $/
so now we are checking for 000 or 00 to 199 or 200 to 249 or 250 to 255
followed by \.
 Now I should have this right. Making mistakes sure helps you learn and
think things through more thoroughly.
How is that or do you have anymore suggestions.
As someone else pointed out, you are rapidly approaching the REGEX given 
in the Perl Cookbook.  Once you add a case to handle single digit 
numbers you will be there.

The only other differences are that you are using {0,1} which is exactly 
the same as ?, and you are using [0-9] which is exactly the same and \d. 
 In both cases, the latter of the two equivalent expressions is shorter 
to express, and used by the REGEX in the Perl Cookbook.



- Original Message - 
From: "Jamie Murray" <[EMAIL PROTECTED]>
To: "$Bill Luebkert" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 9:40 AM
Subject: Re: REGEX help!



BiLL,
If you check my second post I made the correction but I'm still correct in
my example and method.
Actually the e-mail from Raul Davletshin pretty much verifys what I had
also stated and he's also correct.
As for explaining [0-2]  0 or 1 or 2 are all possibilities of course but
only one(unless using ? but thats another story)
so wheres the problem your explaining something we already know.
Also the example I gave Alex can be adjusted to his needs using class []
and range {}. At least he will know how to put together
some type of expression that works instead of just relying on built in
functions.
As for your post down below you can check numbers that way.
Did you run this in a script before you decided it doesn't work because it
worked perfectly for me.
Please run what I have below and correct what is "actually incorrect" not
what you "think is incorrect"
I'm all for learning and am just trying my best.
Thanks!

- Original Message - 
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 5:07 AM
Subject: Re: REGEX help!



Jamie Murray wrote:


Hey Alex,
I jumped a little quick there, the previous post does work but I had a
doh

moment and forgot your upper range match could only be 254 at most.
Sorry about that.
if($num =~

/^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)

^^^  ^^^  ^^^
The digits can be 0-9, not 0-2, 0-4 or 0-5.  eg: 192.168.0.1 is a legal
IP

You can't check a number range this way.


after each class [] use {num,num} to adjust for a part of the ip not
having

a number.

so for example

if($num =~


/^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)

matches ip's like these
"three digit 254 or less"."three digit 254 or less"."three digit 254
or

less"."three digit 254 or less".
or
"two digit 54 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less"


--
 ,-/-  __  _  _ $Bill Luebkert
Mailto:[EMAIL PROTECTED]

(_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
 / ) /--<  o // //  Castle of Medieval Myth & Magic
http://www.todbe.com/

-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

--
Glenn -- http://nevcal.com/
===
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


BitBlt (was: Help Mee...)

2004-01-13 Thread Johan Lindstrom
At 19:45 2004-01-13, Asim Siddiqui wrote:
BitBlt(Picture1.hdc,Picture1.current_X,Picture1.current_Y,Picture1.Width,Picture1.Height,Picture2.hdc,Picture2.current_X,Picture2.current_Y,&HC002)
Do you use Win32::API to call this routine? What does Perl code that 
defines this routine look like?


Now I've made it completely rewritten in PERL but only aq black box 
appears on the Window who's hdc I've given to the function.Is there any 
exception that PICTURE editing will work under PERL.However, I've used the 
API of the following sections:
The source device context (Picture2.hdc), where does it come from? Is it a 
Win32::GUI::DC, or another window's dc, or how do you create it? Please 
show us code.

/J

 --  --- -- --  --  -- -  - -
Johan Lindström   Sourcerer @ Boss Casinos   [EMAIL PROTECTED]
Latest bookmark: "The New Yorker Fact"
http://www.newyorker.com/fact/content/?040112fa_fact
dmoz (1 of 24): /Arts/Literature/Authors/K/ 326
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Press any key to exit

2004-01-13 Thread Thomas, Mark - BLS CTR
> Anyone have a better idea of how to do "press any key to 
> exit" than the example below. A google search only yielded 
> the same idea I had

Interesting how people tend to start and end searches these days with
Google. Next time you may want to check the FAQ. The answer to this question
is in PerlFaq8.

>From a command prompt, 'perldoc perlfaq' will give you the index, and then
'perldoc perlfaqX' where X is a FAQ number.

Or use the FAQ search: 'perldoc -q keyboard' would have given you the
answer.

Or, using our beloved Google, enter 'keyboard site:perldoc.com' and you'll
find it.


-- 
Mark Thomas[EMAIL PROTECTED]
Internet Systems Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Help Mee...

2004-01-13 Thread Asim Siddiqui
Hello,
Its a PERL API problem.Would someone help...
Like in VB I've written a script that:
BitBlt(Picture1.hdc,Picture1.current_X,Picture1.current_Y,Picture1.Width,Picture1.Height,Picture2.hdc,Picture2.current_X,Picture2.current_Y,&HC002)

Now I've made it completely rewritten in PERL but only aq black box appears 
on the Window who's hdc I've given to the function.Is there any exception 
that PICTURE editing will work under PERL.However, I've used the API of the 
following sections:

1) BRUSH
2) PEn
3) PATHS AND REGIONS
 And all the other drawing API's...

Regards,
Asim Siddiqui
_
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: In your opinion, what's a good second languange to learn?

2004-01-13 Thread Chris
This would depend on what you plan to program in the future. I.e. c/c++ and
VB would be good if you want to get into Windows application development,
Java/c# would be good to learn for mobile devices. Every language has it's
pros and cons for a given platform or use.


Regards, 

Chris


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, January 13, 2004 11:41 AM
To: [EMAIL PROTECTED]
Subject: In your opinion, what's a good second languange to learn?


Hi All,

I need some advise from you out there who have more experience with 
development.  The only language I know is Perl.  I have been using it for 
more than two years now.  I had accomplished all tasks I needed to do at 
work (as an IT Support person) quite easily.  I really like programming 
and I'd like to be a software developer in the next coming years.  When I 
look at the job market right now, companies are looking for developers who 
know a lot of programming languages, Perl, Java, C, C++, VB, Python, 
etc...  But I just have so little time to study all of these.  So in your 
opinion, If I want to be bilingual and if I want to go into software 
development, which second language would be best?

Regards,
Sam
___
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: network inventory, how do YOU do it?

2004-01-13 Thread Javier Nunez
The problem that I got it was to make an inventory of what it was
installed in the servers of our world wide network. I got several
options to retrieve the name and OS that were running the servers in
order to know where the software was installed.

Like we do not know if the IP address were in use or not I have to find
that out first. So I ping the server to ensure that if was a response
and then try to scan the ports. The ping that I use makes 4 attempts
(why 4, well some times the servers are configure to not respond to
pings from outside but they just cover the icmp ping je,je!)

A. by ICMP
B. by UDP
C. by TCP
D. by TCP/HTTP port 80 or any other of the ports used by HTTPS like 389,
390 1000, 1389 (just in case that they have installed a web server) this
one works if they don't change the default ports (there are some guys
who does that for security)

If any of this responds and the port was open (another subroutine) then,
I just proceed with the port scan, otherwise it doesn't make sense to
scan a server with closed ports (at least the ones that I'm interested).

Well, the part that you may be interested is that I could ask the Server
name and the OS by different ways if the other was closed. So this is
what I used:

1. SNMP
   If you use the SNMP you can establish a session with Net::SNMP and se
the correct string to ask for the OS name then you can retrieve most of
the information that you want. The problem with this is that the
community has to be set to "public" on the server that you want retrieve
the information; if the community has been change then you will need to
belong to that community in order to retrieve that information.

Don't know the amount of equipment that you got installed but be ready
to use a lot of Regular Expressions. I got responses from Ciscoes,
Terminal Servers Printers, Scanners, Operative Systems (all kinds of
UNIX and windows),etc. If you check as well not all the Ciscos reply to
you with the same string, it depends on the OS version the order of the
string in order to obtain the correct version of it.


2. Use SMTP
   Realize a connection on the port 25 to retrieve the information of
the e-mail so you can get the information of what server is and the
sendmail (or whatever program they are using for e-mail) version. After
this you realize a DNS search on you network to determine the IP address
of the given server name. This is useful if the other end is a server
but not useful when you get a response from a printer !!

On this one as in the point one, be ready for the Regular Expressions
because (again) depending on you equipment you can get such a variety of
responses like Sendmail, lotus. Microsoft, IBM (if you find AS/400
equipment). Be ready as well to retrieve data of e-mail scanners that
are occupy the port 25 such as interscan, webshield, etc.

3. If the IP responded to the HTTP scan then I use the LWP to retrieve
the information that I wanted (Hostname, IP address, or if it was a
proxy) and some data that may not be interested to you like what kind of
web server they got like Netscape, Microsoft, Apache, Lotus, etc.)

This is what I did, you ask for no code (I respect that !) and I hope
this helps you.

Saludos

Javier

-Original Message-
From: Hon Shi [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 13, 2004 5:50 AM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: network inventory, how do YOU do it?



How does one go out and "inventory" his network.
In other words, given a hot IP (it pings) how can
you discover just exactly what is there?

Don't write anything for me but just generally describe
the method.  It's generally a W2K world, but we have
net phones, unix boxes, printers and 

Thanks

(I've seen a trial package that 'scans' the network collecting all kinds
of info.  It reports its progress to the screen, things like '...
ICMP..., SNMP', and so forth. It found the net phone, it's http port
and mfgr information.  How did they do it? Scripts that ping and some
wmi is about as far as I've gone.)

PS - my company isn't going to buy anything (except that Lincoln for the
boss :-)


__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: network inventory, how do YOU do it?

2004-01-13 Thread Jarvis, John

To get a physical inventory:

"Given a hot IP", SNMP works well (low bandwidth, widely implemented, lots
of useful info). Unfortunately, 'Discovery' can be a problem if you haven't
enabled your network hosts to respond (Windows pc's are off by default). 

Also, 'Net::NBName' can deliver Windows PC info 



To survey ports/services:

TMTOWTDI.  Decide what the right answer looks like and a Perl solution will
usually present itself.


If done in Perl, it's free! And easy (relatively).

HTH

-Original Message-
From: Hon Shi [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 13, 2004 4:50 AM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: network inventory, how do YOU do it?



How does one go out and "inventory" his network.
In other words, given a hot IP (it pings) how can
you discover just exactly what is there?

Don't write anything for me but just generally describe
the method.  It's generally a W2K world, but we have
net phones, unix boxes, printers and 

Thanks

(I've seen a trial package that 'scans' the network collecting
all kinds of info.  It reports its progress to the screen, things
like '... ICMP..., SNMP', and so forth. It found the net phone,
it's http port and mfgr information.  How did they do it?
Scripts that ping and some wmi is about as far as I've gone.)

PS - my company isn't going to buy anything (except that Lincoln for
the boss :-)


__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
___
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Delphi problem (It _is_ related).

2004-01-13 Thread Johan Lindstrom
At 13:47 2004-01-13, Beckett Richard-qswi266 wrote:
I've just been handed a GUI based program that's been written in Delphi 7
(whatever that is).
I think that Delphi is a GUI builder that's based on Pascal. Does anyone
know if there's a Perl vesrion, or can I convert what's already been done
into perl somehow?
If you are Windows-only anyway, go with Win32::GUI (depending on how 
complex the GUI is. If it's _very_ complex, I could be temted to go with 
wxWindows instead).

Win32::GUI PPMs and controls
http://perso.club-internet.fr/rocherl/Win32GUI.html
GUI Designer
http://www.darserman.com/Perl/Loft/

Or is it time to learn Pascal?
Probably, yes, if the application is well written and non-trivial. I think 
you could be much worse off than Delphi.

/J

 --  --- -- --  --  -- -  - -
Johan Lindström   Sourcerer @ Boss Casinos   [EMAIL PROTECTED]
Latest bookmark: "The New Yorker Fact"
http://www.newyorker.com/fact/content/?040112fa_fact
dmoz (1 of 24): /Arts/Literature/Authors/K/ 326
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Delphi problem (It _is_ related).

2004-01-13 Thread Manfred . Beilfuss
Guy,
about what are you talking,
  a perl version of   delphi,
  pascal
  or what,

 H 

Or are you just having some fun with us ???

Best regards
Guy G



   

Beckett Richard-qswi266

<[EMAIL PROTECTED]>   An: "'[EMAIL PROTECTED]'"
 
Gesendet von:<[EMAIL PROTECTED]>   

[EMAIL PROTECTED]Kopie:

eState.com   Thema:  Delphi 
problem (It _is_ related). 
   

   

13.01.2004 13:47   

   

   





Guys,

I've just been handed a GUI based program that's been written in Delphi 7
(whatever that is).

I think that Delphi is a GUI builder that's based on Pascal. Does anyone
know if there's a Perl vesrion, or can I convert what's already been done
into perl somehow?

Or is it time to learn Pascal?

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread Jamie Murray
BiLL,
If you check my second post I made the correction but I'm still correct in
my example and method.
 Actually the e-mail from Raul Davletshin pretty much verifys what I had
also stated and he's also correct.
As for explaining [0-2]  0 or 1 or 2 are all possibilities of course but
only one(unless using ? but thats another story)
 so wheres the problem your explaining something we already know.
Also the example I gave Alex can be adjusted to his needs using class []
and range {}. At least he will know how to put together
some type of expression that works instead of just relying on built in
functions.
As for your post down below you can check numbers that way.
Did you run this in a script before you decided it doesn't work because it
worked perfectly for me.
Please run what I have below and correct what is "actually incorrect" not
what you "think is incorrect"
 I'm all for learning and am just trying my best.

Thanks!


- Original Message - 
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 13, 2004 5:07 AM
Subject: Re: REGEX help!


> Jamie Murray wrote:
>
> > Hey Alex,
> > I jumped a little quick there, the previous post does work but I had a
doh
> > moment and forgot your upper range match could only be 254 at most.
> > Sorry about that.
> >
> > if($num =~
> > /^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
>  ^^^  ^^^  ^^^
> The digits can be 0-9, not 0-2, 0-4 or 0-5.  eg: 192.168.0.1 is a legal IP
> You can't check a number range this way.
>
> >  after each class [] use {num,num} to adjust for a part of the ip not
having
> > a number.
> >
> > so for example
> >
> > if($num =~
> >
/^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
> > matches ip's like these
> >  "three digit 254 or less"."three digit 254 or less"."three digit 254 or
> > less"."three digit 254 or less".
> > or
> > "two digit 54 or less"."three digit 254 or less"."three digit 254 or
> > less"."three digit 254 or less"
>
>
> -- 
>   ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
>  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
>   / ) /--<  o // //  Castle of Medieval Myth & Magic
http://www.todbe.com/
> -/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Delphi problem (It _is_ related).

2004-01-13 Thread Beckett Richard-qswi266
Guys,

I've just been handed a GUI based program that's been written in Delphi 7
(whatever that is).

I think that Delphi is a GUI builder that's based on Pascal. Does anyone
know if there's a Perl vesrion, or can I convert what's already been done
into perl somehow?

Or is it time to learn Pascal?

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


network inventory, how do YOU do it?

2004-01-13 Thread Hon Shi

How does one go out and "inventory" his network.
In other words, given a hot IP (it pings) how can
you discover just exactly what is there?

Don't write anything for me but just generally describe
the method.  It's generally a W2K world, but we have
net phones, unix boxes, printers and 

Thanks

(I've seen a trial package that 'scans' the network collecting
all kinds of info.  It reports its progress to the screen, things
like '... ICMP..., SNMP', and so forth. It found the net phone,
it's http port and mfgr information.  How did they do it?
Scripts that ping and some wmi is about as far as I've gone.)

PS - my company isn't going to buy anything (except that Lincoln for
the boss :-)


__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Copying directories.

2004-01-13 Thread Johan Lindstrom
At 11:08 2004-01-13, Beckett Richard-qswi266 wrote:
I thought this woule be a lot easier than it seems...

All I want to do is to copy a directory, and everything it contains
(whatever this may be) to a new directory.
-snip-
What's the nice and easy way to do this?
The CPAN way of course ;)
http://search.cpan.org/~mzsanford/File-NCopy-0.34/
/J

 --  --- -- --  --  -- -  - -
Johan Lindström   Sourcerer @ Boss Casinos   [EMAIL PROTECTED]
Latest bookmark: "The New Yorker Fact"
http://www.newyorker.com/fact/content/?040112fa_fact
dmoz (1 of 24): /Arts/Literature/Authors/K/ 326
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Copying directories.

2004-01-13 Thread Tfbsr Bertrand
Found this bit of code on the web recently...
 
sub copydir { my ($dir, $to) = @_;
 print "copying $dir to $to\n"; opendir IN, $dir or die "what is this: $dir"; my @list = readdir IN; closedir IN;
 if (! -d $to) { mkdir $to, 0777; } foreach my $i (@list) { my $file = "$dir/$i";
 if ( -d "$file") { if  (( $i ne ".") && ( $i ne "..")) { ©dir( "$file", "$to/$i"); } } elsif (-f "$file") { copy("$file","$to/$i"); } else { print "Hey, whats this?? $file\n"; } }}
Beckett Richard-qswi266 <[EMAIL PROTECTED]> wrote:
Guys,I thought this woule be a lot easier than it seems...All I want to do is to copy a directory, and everything it contains(whatever this may be) to a new directory.I (finally) managed it with a system command:if (system "xcopy /E/I/C \"$default_path\" \"$new_path\"") {print "Copyfailed\n$!\n";die};but it's _really_ horrible, and not portable.What's the nice and easy way to do this?Thanks.R.___Perl-Win32-Users mailing list[EMAIL PROTECTED]To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes

Copying directories.

2004-01-13 Thread Beckett Richard-qswi266
Guys,

I thought this woule be a lot easier than it seems...

All I want to do is to copy a directory, and everything it contains
(whatever this may be) to a new directory.

I (finally) managed it with a system command:

if (system "xcopy /E/I/C \"$default_path\" \"$new_path\"") {print "Copy
failed\n$!\n";die};

but it's _really_ horrible, and not portable.

What's the nice and easy way to do this?

Thanks.

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread $Bill Luebkert
Jamie Murray wrote:

> Hey Alex,
> I jumped a little quick there, the previous post does work but I had a doh
> moment and forgot your upper range match could only be 254 at most.
> Sorry about that.
> 
> if($num =~
> /^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
 ^^^  ^^^  ^^^
The digits can be 0-9, not 0-2, 0-4 or 0-5.  eg: 192.168.0.1 is a legal IP
You can't check a number range this way.

>  after each class [] use {num,num} to adjust for a part of the ip not having
> a number.
> 
> so for example
> 
> if($num =~
> /^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
> matches ip's like these
>  "three digit 254 or less"."three digit 254 or less"."three digit 254 or
> less"."three digit 254 or less".
> or
> "two digit 54 or less"."three digit 254 or less"."three digit 254 or
> less"."three digit 254 or less"


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread Glenn Linderman
On approximately 1/12/2004 8:36 PM, came the following characters from
the keyboard of Jamie Murray:
Hey Alex,
I jumped a little quick there, the previous post does work but I had a doh
moment and forgot your upper range match could only be 254 at most.
Sorry about that.
if($num =~
/^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
 after each class [] use {num,num} to adjust for a part of the ip not having
a number.
so for example

if($num =~
/^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
matches ip's like these
 "three digit 254 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less".
or
"two digit 54 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less"
Oh please.  Think about some test cases.

Do you think that Alex would want to match 192.168.10.10 ?  I think so, 
but your regex wouldn't.

See $Bill's reply, or the original Cookbook expression, for a much 
better suggestion.

But to get back to one of the questions that Alex originally asked:

alex p wrote:
I have been trying to find a regex to validate IP ranges and found the 
following:

m{
   ^  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
  \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
  \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
  \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
   $   # from the Perl Cookbook, Recipe 
6.23,
   }xo # pages 218-9, as fixed in the 01/00 
reprint

can someone explain this REGEX to me
The first thing one observes by the structure of the above REGEX is that 
it consists of 4 repeated identical expressions (one on each line).  The 
first one starts at the beginning of the string (^), the last one ends 
at the end of the string ($), and they are separated by periods (\.).

Now let's examine one of the repeated groups.  Each group has 4 
alternatives, each separated by |.

Alternative 1 is any single digit.  This covers the range of values from 
0-9 inclusive.

Alternative 2 is any pair of digits, or optionally any pair of digits 
preceeded by either 0 or 1.  This covers the range of values from 0-199 
inclusive.  Note that I did NOT say it covers the range of values from 
10-199... the values from 0-9 can also legally be expressed as 01 - 09, 
or 001 - 009.

Alternative 3 is a 2, followed by a digit from 0-4, followed by any 
digit.  This covers the range of values:  200-209, 210-219, 220-229, 
230-239, and 240-249, the union of which is 200-249.

Alternative 4 is 25, followed by a digit from 0-5, so it covers the 
range of values from 250-255.

Put together, the alternatives cover the complete range of 1 to 3 digit 
numbers ranging in value from 0-255.

The whole expression covers the complete range of 1 to 3 digit numbers 
ranging in value from 0-255, grouped in 4 groups separated by a single 
period character.  This is the usual form for expressing IP addresses.

--
Glenn -- http://nevcal.com/
===
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread Raul Davletshin
f ($ip =~ /^\d[0-254]\.\d[0-254]\.\d[0-254]\.\d[0-254]$/)
incorect way of matching ip address, it will work fore "61.14.95.02", 
but will not work for "66.18.99.07". The problem here you just trying to 
match 2 digital number instead of 3 digits. For example using "[]" [aDc] 
true for "a" but not for "aa", or true for "D"  but not for "aDc".

\d => 0 1 2 3 4 5 6 7 8 9
[01]? => match zero or more occurrence of 0 OR 1.
[0-4]  => 0 1 2 3 4, but not all of them at same time.
now your code:
[0-254] => will match 0 1 2 4 5.
alex p wrote:

Hello all,
I have been trying to find a regex to validate IP ranges and found the 
following:

m{
  ^  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
 \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
 \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
 \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
  $   # from the Perl Cookbook, Recipe 
6.23,
  }xo # pages 218-9, as fixed in the 
01/00 reprint

can someone explain this REGEX to me

I have done the following but its not working:

if ($ip =~ /^\d[0-254]\.\d[0-254]\.\d[0-254]\.\d[0-254]$/)
{
  print "$ip is valid\n";
}
 else {print "$ip is invalid\n";}
}
TYIA

_
There are now three new levels of MSN Hotmail Extra Storage!  Learn 
more. http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: REGEX help!

2004-01-13 Thread Jamie Murray
Hey Alex,
I jumped a little quick there, the previous post does work but I had a doh
moment and forgot your upper range match could only be 254 at most.
Sorry about that.

if($num =~
/^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
 after each class [] use {num,num} to adjust for a part of the ip not having
a number.

so for example

if($num =~
/^[0-2]{0,1}[0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/)
matches ip's like these
 "three digit 254 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less".
or
"two digit 54 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less"





- Original Message - 
From: "alex p" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 12, 2004 11:56 AM
Subject: REGEX help!


> Hello all,
> I have been trying to find a regex to validate IP ranges and found the
> following:
>
> m{
>^  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
>   \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
>   \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
>   \.  ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
>$   # from the Perl Cookbook, Recipe
> 6.23,
>}xo # pages 218-9, as fixed in the
01/00
> reprint
>
> can someone explain this REGEX to me
>
> I have done the following but its not working:
>
> if ($ip =~ /^\d[0-254]\.\d[0-254]\.\d[0-254]\.\d[0-254]$/)
> {
>   print "$ip is valid\n";
> }
>   else {print "$ip is invalid\n";}
> }
>
> TYIA
>
> _
> There are now three new levels of MSN Hotmail Extra Storage!  Learn more.
> http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs