Re: perl and pattern

2012-02-23 Thread Igor Dovgiy
2012/2/23 Rob Dixon > > Negative numbers aside, it seems more straightforward to insist that > there are no non-digit numbers in the input, hence > That's definitely an option, but I'm not in favor of 'double negation' conditionals usually, as they might be confusing. For example, I use only wh

Re: perl and pattern

2012-02-22 Thread Rob Dixon
On 22/02/2012 20:48, Igor Dovgiy wrote: TL;DR: the core of your program may be rewritten as... print 'Please, enter an integer number, as I really need it: '; chomp (my $user_input =); if ($user_input =~ /^-?\d+$/) { print "My hero! You've actually entered<$user_input>, which is an integer!

Re: perl and pattern

2012-02-22 Thread Igor Dovgiy
...Well, there were no 'only latin number symbols are allowed in user input' clauses, so \d seems to be more suitable than mere [0-9]. And for most of my cases \d was sufficient yet shorter than [0-9] - and more readable, somewhat ironically... There goes 'why' part. ) And we both, I suppose, may

Re: perl and pattern

2012-02-22 Thread Dr.Ruud
On 2012-02-22 21:48, Igor Dovgiy wrote: Anyway, if you're looking for integers only, as assumed previously, the corresponding check should be made of this: *match the beginning of the line marker, then, optionally, a minus sign, then any number of digits, then the end of the line marker*, or jus

Re: perl and pattern

2012-02-22 Thread Igor Dovgiy
What a pleasant thread we've got here. ) Suppose a bit of my ranting won't spoil it much, will it? )) 2012/2/21 Vyacheslav > I'm new in perl and have many questions. > And there's a place to ask them, believe me. ) > This my first programm. > Going straight to the point, I see... Good. But i

Re: perl and pattern

2012-02-22 Thread Vyacheslav
Hello there. Thank you. Deal with all 22.02.2012 05:11, John W. Krahn пишет: Shlomi Fish wrote: On Tue, 21 Feb 2012 23:47:39 +0400 Vyacheslav wrote: I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; That's good. my $number = 0;

Re: perl and pattern

2012-02-21 Thread John W. Krahn
Shlomi Fish wrote: On Tue, 21 Feb 2012 23:47:39 +0400 Vyacheslav wrote: I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; That's good. my $number = 0; my $_ = 0; You shouldn't use my with "$_" and you should avoid using $_ in

Re: perl and pattern

2012-02-21 Thread John SJ Anderson
Gentlemen, you're both running towards the line marked "on topic for perl-beginners" at a rapid pace. I urge you to consider further messages in this thread carefully, lest that line be crossed. thanks, the list mom. -- John SJ Anderson / geneh...@genehack.org

Re: perl and pattern

2012-02-21 Thread Shlomi Fish
Hello Rob, On Tue, 21 Feb 2012 20:32:19 + Rob Dixon wrote: > On 21/02/2012 19:57, Shlomi Fish wrote: > > Hi, > > > > On Tue, 21 Feb 2012 23:47:39 +0400 > > Vyacheslav wrote: > > > >> Hello. > >> > >> I'm new in perl and have many questions. > >> > >> This my first programm. > >> > >> #!/usr

Re: perl and pattern

2012-02-21 Thread Rob Dixon
On 21/02/2012 19:57, Shlomi Fish wrote: Hi, On Tue, 21 Feb 2012 23:47:39 +0400 Vyacheslav wrote: Hello. I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; That's good. my $number = 0; my $_ = 0; You shouldn't use my with "$_"

Re: perl and pattern

2012-02-21 Thread Rob Dixon
On 21/02/2012 19:47, Vyacheslav wrote: Hello. I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; my $number = 0; my $_ = 0; print "Enter number:"; chomp($number = <>); if ( $number = /[0-9]/) { print "you number $number\n" } ./firsh.pl

Re: perl and pattern

2012-02-21 Thread Lawrence Statton
On 02/21/2012 01:47 PM, Vyacheslav wrote: Hello. I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; EXCELLENT START! my $number = 0; my $_ = 0; print "Enter number:"; chomp($number = <>); if ( $number = /[0-9]/) { You want the matc

Re: perl and pattern

2012-02-21 Thread Shlomi Fish
Hi, On Tue, 21 Feb 2012 23:47:39 +0400 Vyacheslav wrote: > Hello. > > I'm new in perl and have many questions. > > This my first programm. > > #!/usr/bin/perl > > use strict; > use warnings; > That's good. > my $number = 0; > my $_ = 0; You shouldn't use my with "$_" and you should avoid

perl and pattern

2012-02-21 Thread Vyacheslav
Hello. I'm new in perl and have many questions. This my first programm. #!/usr/bin/perl use strict; use warnings; my $number = 0; my $_ = 0; print "Enter number:"; chomp($number = <>); if ( $number = /[0-9]/) { print "you number $number\n" } ./firsh.pl Enter number: 23 I thought, what print