Re:

2011-09-05 Thread Shawn H Corey
On 11-09-05 03:22 PM, Shlomi Fish wrote: One option would be to check that $_ matches the regular expression /\A[1-7]\z/ Another is to write a sub you can re-use: #!/usr/bin/env perl use strict; use warnings; use Scalar::Util qw( looks_like_number ); sub choose_from_menu { my ( @menu ) =

Re: Clarification on the use of "my"

2011-09-05 Thread Rob Dixon
On 05/09/2011 19:54, Uri Guttman wrote: it doesn't matter the language or the comments. single letter var names are just bad coding. names are a communication to the reader of the code, not a placeholder or whatever to the coder. much more work needs to be put into choosing good names than most

Re: Clarification on the use of "my"

2011-09-05 Thread Rob Dixon
On 05/09/2011 16:51, Uri Guttman wrote: there is no such thing as module scope. our declares package globals and give them a short name in a lexical scope. All software comcepts exist only in someone's imagination. Brandon and I can imagine what 'module scope' means and I am surprised that you

Re:

2011-09-05 Thread Chris Stinemetz
> > I should also note that one would use Ctrl+D instead of Ctrl+Z for EOF in > UNIX-land. > Thank you Shlomi. I am currently in the windows-land. I was not aware of the warn function. Learn something new everyday! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands

Re: Clarification on the use of "my"

2011-09-05 Thread Uri Guttman
> "BM" == Brandon McCaig writes: BM> On Mon, Sep 5, 2011 at 2:54 PM, Uri Guttman wrote: >> it doesn't matter the language or the comments. single letter var names >> are just bad coding. names are a communication to the reader of the >> code, not a placeholder or whatever to the code

Re:

2011-09-05 Thread Shlomi Fish
On Mon, 5 Sep 2011 14:10:35 -0500 Chris Stinemetz wrote: > In exercise 3-3 from the lama book. > > How do you make sure the user enters a number 1 thru 7? > > The simple program is: > > #!/usr/bin/perl > use warnings; > use strict; > my @names = qw/ fred betty barney dino wilma pebbles bamm-ba

Re: Clarification on the use of "my"

2011-09-05 Thread Brandon McCaig
On Mon, Sep 5, 2011 at 2:54 PM, Uri Guttman wrote: > it doesn't matter the language or the comments. single letter var names > are just bad coding. names are a communication to the reader of the > code, not a placeholder or whatever to the coder. much more work needs > to be put into choosing good

beginners@perl.org

2011-09-05 Thread Chris Stinemetz
In exercise 3-3 from the lama book. How do you make sure the user enters a number 1 thru 7? The simple program is: #!/usr/bin/perl use warnings; use strict; my @names = qw/ fred betty barney dino wilma pebbles bamm-bamm /; print "Enter some numbers from 1 to 7, one per line, then press Ctrl-Z:\n

Re: Clarification on the use of "my"

2011-09-05 Thread Uri Guttman
> "BM" == Brandon McCaig writes: BM> On Mon, Sep 5, 2011 at 11:51 AM, Uri Guttman wrote: >> single letter variable names are bad in general. they tell you nothing >> about the use and content of the variable. about the only exception are >> $i and $j for array/matrix indexing and th

Re: Clarification on the use of "my"

2011-09-05 Thread Brandon McCaig
On Mon, Sep 5, 2011 at 11:51 AM, Uri Guttman wrote: > there is no such thing as module scope. our declares package globals and > give them a short name in a lexical scope. Ah, yes, thank you for correcting me. :) The line between "module" and "package" had blurred on me. Google cleared that up.

Re: Clarification on the use of "my"

2011-09-05 Thread Uri Guttman
> "BM" == Brandon McCaig writes: BM> On Sun, Sep 4, 2011 at 11:53 PM, flebber wrote: >> For this example. the first two assignments work okay, but then at $c >> if I do not declare my local then I get an error. $d also requires >> that it be assigned using my, though it is directly t

Re: more oop array

2011-09-05 Thread Rob Dixon
On 03/09/2011 22:25, Uri Guttman wrote: >> "RD" == Rob Dixon writes: > >RD> On 03/09/2011 21:34, Uri Guttman wrote: >>> Ron Weidner wrote: >>> >>> first off, arrays have nothing (or little) to do with OOP. you are > using >>> arrays inside an object but the code at

Re: Code organization .pm

2011-09-05 Thread Shawn H Corey
On 11-09-05 02:12 AM, Shlomi Fish wrote: I should note that you may be prematurely optimising here, so you shouldn't worry about getting a lot of code compiled, until you are sure it's the bottleneck: http://c2.com/cgi/wiki?PrematureOptimization I have to agree with Shlomi. I also think that

Re: Clarification on the use of "my"

2011-09-05 Thread Brandon McCaig
On Sun, Sep 4, 2011 at 11:53 PM, flebber wrote: > For this example. the first two assignments work okay, but then at $c > if I do not declare my local then I get an error. $d also requires > that it be assigned using my, though it is directly the same as $b, my > assumption here is that $d require

Clarification on the use of "my"

2011-09-05 Thread flebber
Just a quick question on the need of "my" http://perldoc.perl.org/functions/my.html Was using an example from the beginning perl text in the example he gave he wasn't using strict but i have it on to all scripts by default. For this example. the first two assignments work okay, but then at $c if