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 ) =
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
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
>
> 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
> "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
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
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
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
> "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
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.
> "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
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
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
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
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
15 matches
Mail list logo