Hello Rob, On Tue, 21 Feb 2012 20:32:19 +0000 Rob Dixon <rob.di...@gmx.com> wrote:
> On 21/02/2012 19:57, Shlomi Fish wrote: > > Hi, > > > > On Tue, 21 Feb 2012 23:47:39 +0400 > > Vyacheslav<agapov.sl...@gmail.com> 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". > > Shlomi your comments are generally finicky but this is inexcusable. > > The OP is a Perl beginner, and is hardly likely to be writing 'serious > programs'. Larry designed $_ to make Perl more natural and fluid, and > avoiding it for all but the most complex of applications is to deny much > of what Perl is very good at. > I think $_ should generally be avoided for all but the *simplest* of programs (e.g: one-liners, etc.). In the most complex applications, it has no place, except when required by functions such as sort, map, grep, or the List::Util or List::MoreUtils functions. Even then, it is sometimes useful to assign $_ to a lexical variable within its scope. The problem with $_ is that it can get clobbered and devastated *extremely* easily. If we think of "$_" as Perl's equivalent to the word "it", then after you introduce enough nouns in the sentence or its contexts, you won't know what "it" refers to. > There is no reason to require an article in an English phrase, In that case, why are the following two sentences different: * "It raised few eyebrows." * "It raised a few eyebrows." > and if we > are to follow your guidance then we mustn't ever say "I like cheese". You can say that because cheese is an uncountable noun. But "number isn't, and you cannot say "I like number.". > You are surely used to prompts like "Enter password", or even simply > "Password"? Yes, these are intended for brevity, but such extreme conformance to brevity is not desirable here. And arguably "Enter password" could be short for "Enter the password". > > You often seem to me to be flexing the biceps of your programming > knowledge, and I think you should remember that that is usually > detrimental to anything you could teach. > Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ My Public Domain Photos - http://www.flickr.com/photos/shlomif/ C++ supports Object‐Oriented Programming roughly as much as COBOL supports Functional Programming. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/