Hi,
On Tue, 21 Feb 2012 23:47:39 +0400
Vyacheslav <[email protected]> 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 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. You should use "=~" (the pattern match operator) instead of
"=" (the assignment one). A non-bound /.../ will match against $_. You may also
wish to use \d instead of [0-9] (though this will also match the digits used in
Arabic, etc.)
> print "you number $number\n"
1. Always include semicolons - even at end of blocks. That way your code won't
emit many spurious errors if you add more statements later.
2. You should write "Your number is $number.\n"; (Grammar nitpick).
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html
Judaism: God knows you will do shit, does nothing to prevent it, but makes you
take the blame for it anyways.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/