Jerald Sheets wrote:
>
> On Mar 8, 2009, at 1:29 PM, Ron Bergin wrote:
>
>> On Mar 4, 4:46 am, que...@gmail.com (Jerald Sheets) wrote:
>>>
>>> I really think you're doing yourself a disservice by just throwing
>>> your program commands on lines, not indenting according to best
>>> practices.  It makes your code unreadable, and can make it very hard
>>> to debug the more involved your programs get.
>>>
>> [snip]
>>
>>> Consider picking up Damian's book:
>>>
>>> http://oreilly.com/catalog/9780596001735/index.html
>>>
>>> It'll serve you well and is a must have for the serious perl
>>> programmer.
>>>
>> I agree, however your code as shown below doesn't follow "Perl Best
>> Practices".
>>
>> You use improper indentation, and failed to use vertical whitespace
>> making it harder to read/follow.
>>
>>> #!/usr/bin/perl -w
>>>
>> It's better to use the warnings pragma, instead of the -w switch
>
>
[snip]

> Whether fully complying with Damian's book or not, you cannot argue
> the difference in readability (my point of the messages) in comparison
> to what was offered.

Actually, I can make that argument.  The readability of your code wasn't any
better than the OP's.  In fact yours was more confusing due to the improper
use of indentation.  Indentation is done at the block level and when breaking
up a long statement across multiple lines.  Your indentation made me think I
missed an initialization of a block which made me re-read that portion of code
each time you indented.

[snip]
>
> However on the -w switch, here are Damian's words:
>
> 18.8. Warnings
>
> Always turn on warnings explicitly.
>
> If you're developing under Perl 5.6 or later, always use warnings at
> the start of each file. Under earlier versions of Perl, always use the
> -w command-line flag, or set the $WARNING variable (available fromuse
> English) to a true value.
>
[snip]
>
>
> He appears to insinuate they are interchangeable with the phrase:
>
> "always use the -w command-line flag, or set the $WARNING variable
> (available fromuse English) to a true value."
>
They are interchangeable to a degree.  The difference is in their scope and
granularity.  The pragma is lexically scoped and the the -w switch is global
which includes files loaded with use or require.  The pragma can
enable/disable warnings with fine granularity, but the -w switch is all or
nothing.

> How would one know or be aware of anything different?  Where would I
> find that information?  I looked throughout the book, and this was the
> only reference to warnings I could find.  Is there another reference
> you are citing?  Where can I find it?
>
Don't limit yourself to 1 resource.  Read the documentation that comes with
perl (i.e., perldoc) as well as the vast resource of documentation on CPAN.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to