Hello David, some comments on your code.
On Wed, 12 Jun 2013 15:53:32 -0700 David Christensen <dpchr...@holgerdanske.com> wrote: > On 06/12/13 02:28, lee wrote: > > Yes, I've been looking at descriptions like that and I don't know perl > > well enough to understand them. > ... > > This is why I was looking for an example so I can see how these things > > are being used. > > Does this make sense? > > 2013-06-12 15:51:48 dpchrist@desktop ~/sandbox/perl > $ cat Digest.pl > #!/usr/bin/perl > use Digest::MD5 qw(md5_hex); > use File::Slurp; > for (@ARGV) { > print "$_: ", md5_hex(read_file $_), "\n"; > } 1. You're lacking strict and warnings: http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings 2. You're looping using $_ : http://perl-begin.org/tutorials/bad-elements/#overuse_dollar_underscore 3. You're using md5_hex by slurping the contents of the file into memory, which may be very large. It is better to let it read from the file handle, or the filename directly. 4. read_file was not explictly imported from File::Slurp: http://perl-begin.org/tutorials/bad-elements/#non_explicitly_imported_symbols ( Note that the perl-begin.org site is my work, but I base my advice on other sources. ). > > 2013-06-12 15:51:51 dpchrist@desktop ~/sandbox/perl > $ perl Digest.pl cgi*.pl > cgi_cookie.pl: 073a858f3e7c7d8461743f758bc99a76 > cgi_header.pl: 99b11f007ed9efceb3b500b8a30e0558 > cgi_param.pl: 25b88f62883301d08554cd5707e00d10 > cgi_redirect.pl: 69622c750a131d00b1c30c553fc7d916 > > > I wanted to learn perl for ages and never got around to it. Now I'm > > finding it extremely useful, and I'm learning it the wrong way by not > > starting at the beginning ... > > I learned Perl from three books: > > http://www.mail-archive.com/beginners@perl.org/msg115211.html > Both the Perl Cookbook and Programming Perl are showing their age. There are some more up-to-date resources at http://perl-begin.org/ and http://perl-tutorial.org/ . Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Beginners Site for the Vim text editor - http://vim.begin-site.org/ Chuck Norris doesn’t commit changes, the changes commit for him. — Araujo 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/