develooper Front page | perl.beginners | Postings from February 2012

Re: perl and pattern

Thread Previous | Thread Next
From:
Vyacheslav
Date:
February 22, 2012 01:12
Subject:
Re: perl and pattern
Message ID:
4F44B157.1030602@gmail.com
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<agapov.slava@gmail.com> 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 serious
>> programs as much as possible because it can get devastated too easily.
>>
>>> print "Enter number:";
>>
>> An English typo "Enter number" should be "Enter a number".
>>
>>> chomp($number =<>);
>>> if ( $number = /[0-9]/) {
>>
>> This is wrong.
>
> It is not "wrong", in the sense that the syntax is correct, it just 
> does something different than what the OP intended.
>
>
>> You should use "=~" (the pattern match operator)
>
> m// is the pattern match operator, "m" stands for match. =~ is the 
> binding operator, it binds the left operand to the right operand.
>
>
>
>
> John

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About