Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Reviewed code reviewed again

by particle (Vicar)
on Apr 15, 2004 at 21:37 UTC ( #345564=note: print w/ replies, xml ) Need Help??


in reply to Determine files added/removed (code for magazine article)

ouch, those comments hurt my eyes! consider using the __END__ marker and you can follow with all the free text you want.

# Lines 4 and 5 are good Perl practice. "strict" and "warnings" are p +ragmas # that help prevent Perl programmers from doing silly things in their +programs. #

becomes

__END__ Lines 4 and 5 are good Perl practice. "strict" and "warnings" are pra +gmas that help prevent Perl programmers from doing silly things in their pr +ograms. <code> <p>also, you might consider using here documents rather than multiple +print statements.</p> <code> print OUT "For unique files in OldInventory.txt:\n"; print OUT "IGNORING FILES WITH Tmp OR Temp IN PATHNAME.\n"; print OUT "IGNORING FILES IN THE RECYCLE BIN.\n"; print OUT "IGNORING ALL HISTORY FILES.\n"; print OUT "LOWERCASING ALL FILE AND PATHNAMES BEFORE COMPARING.\n"; print OUT "\n";

becomes clearer, and more maintainable as

print OUT <<EOT; For unique files in OldInventory.txt: IGNORING FILES WITH Tmp OR Temp IN PATHNAME. IGNORING FILES IN THE RECYCLE BIN. IGNORING ALL HISTORY FILES. LOWERCASING ALL FILE AND PATHNAMES BEFORE COMPARING. EOT

it's one more useful concept to teach a user, and not difficult to understand.

~Particle *accelerates*


Comment on Re: Reviewed code reviewed again
Select or Download Code
Re: Re: Reviewed code reviewed again
by Anonymous Monk on Apr 16, 2004 at 04:52 UTC

    Please don't consider using m!^__(?:END|DATA)__$! for documentation purposes. POD I tell you, POD. That's what it is for: Plain Old Documentation! Throwing together information at the end of the script is just as bad, if not worse, than using comments. And comments in gross (pun intended) quantities are horrendous. Besides, typing perldoc ScriptName.pl is a heck of a lot easier than scrounging through a file looking for comments or documentation stuffed in in a DATA clause.

2Re: Reviewed code reviewed again
by jeffa (Chancellor) on Apr 16, 2004 at 04:55 UTC

    Call me crazy, but i would rather use a simple:

    print OUT "For unique files in OldInventory.txt: IGNORING FILES WITH Tmp OR Temp IN PATHNAME. IGNORING FILES IN THE RECYCLE BIN. IGNORING ALL HISTORY FILES. LOWERCASING ALL FILE AND PATHNAMES BEFORE COMPARING. ";
    for something as simple as that. But i would rather maintain your example than multiple print lines any day of the week. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Thanks jeffa, and you're right.

      The production version(s) of this code have *many* more rules and are much more complicated. Also, I frequently get requests to modify the exclusion rules.

      I hope that my audience actually uses this code-- in which case they will want to experiment with their own regexes and I did want to make it easy to hack the output, too.

      Thanks for the comment!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345564]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-08-22 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls