Re: File Size Script Help - Working Version

2012-01-03 Thread Igor Dovgiy
Hi folks, happy new year to everyone. ) John, you're right, of course. ) The filenames in nested directories could well overlap, and using $File::Find::name would be safer. Didn't think of that as a big problem, though, as original script (with 'opendir') ignored all the nested folders overall.

Re: File Size Script Help - Working Version

2012-01-03 Thread Brandon McCaig
Hello: On Sat, Dec 31, 2011 at 02:56:50AM +0200, Igor Dovgiy wrote: $filedata{$_} = [$filesize, $filemd5]; *snip* my ($size, $md5) = @{ $filedata{$filename} }; Alternatively, store a nested hash-reference: $filedata{$File::Find::name} = { md5 = $file_md5, size =

Re: File Size Script Help - Working Version

2012-01-02 Thread Jonathan Harris
On Sat, Dec 31, 2011 at 4:29 AM, John W. Krahn jwkr...@shaw.ca wrote: Igor Dovgiy wrote: Great work, Jonathan! Notice how simple your script has become - and that's a good sign as well in Perl. :) We can make it even simpler, however. As you probably know, Perl has two fundamental types of

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Hi Jonathan, Argh, really stupid mistake by me. ) But let's use it to explain some points a bit further, shall we? A skilled craftsman knows his tools well, and Perl programmer (with CPAN as THE collection of tools of all sizes and meanings) has an advantage here: even if documentation is a bit

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Hi John, yes, good point! Totally forgot this. ) Adding new files to a directory as you browse it is just not right, of course. Possible, but not right. ) I'd solve this by using hash with filenames as keys and collected 'result' strings (with md5 and filesizes) as values, filled by File::Find

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 11:58 AM, Igor Dovgiy ivd.pri...@gmail.com wrote: Hi John, yes, good point! Totally forgot this. ) Adding new files to a directory as you browse it is just not right, of course. Possible, but not right. ) I'd solve this by using hash with filenames as keys and

Re: File Size Script Help - Working Version

2011-12-30 Thread Brandon McCaig
On Thu, Dec 29, 2011 at 03:43:19PM +, Jonathan Harris wrote: Hi All Hello Jonathan: (Disclaimer: I stayed up all night playing Skyrim and am running on about 4.5 hours of sleep.. ^_^) I think most things have already been addressed, but I think Igor might have had a bit of trouble making

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 7:11 PM, Brandon McCaig bamcc...@gmail.com wrote: On Thu, Dec 29, 2011 at 03:43:19PM +, Jonathan Harris wrote: Hi All Hello Jonathan: (Disclaimer: I stayed up all night playing Skyrim and am running on about 4.5 hours of sleep.. ^_^) I think most things have

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Great work, Jonathan! Notice how simple your script has become - and that's a good sign as well in Perl. :) We can make it even simpler, however. As you probably know, Perl has two fundamental types of collections: arrays (where data is stored as a sequence of elements, data chunks) and hashes

Re: File Size Script Help - Working Version

2011-12-30 Thread John W. Krahn
Igor Dovgiy wrote: Great work, Jonathan! Notice how simple your script has become - and that's a good sign as well in Perl. :) We can make it even simpler, however. As you probably know, Perl has two fundamental types of collections: arrays (where data is stored as a sequence of elements, data

Re: File Size Script Help - Working Version

2011-12-29 Thread Jonathan Harris
On Thu, Dec 29, 2011 at 5:08 PM, Igor Dovgiy ivd.pri...@gmail.com wrote: Hi Jonathan, Let's review your script a bit, shall we? ) It's definitely good for a starter, but still has some rough places. #!/usr/bin/perl # md5-test.plx use warnings; use strict; use File::Find; use

Re: File Size Script Help - Working Version

2011-12-29 Thread Igor Dovgiy
Hi Jonathan, Let's review your script a bit, shall we? ) It's definitely good for a starter, but still has some rough places. #!/usr/bin/perl # md5-test.plx use warnings; use strict; use File::Find; use Digest::MD5; use File::Spec; So far, so good. ) my $dir = shift ||

re: File Size Script Help - Working Version

2011-12-29 Thread Jonathan Harris
Hi All Firstly, many thanks for your help previously (19/12/11) - it has led to making a useable script I don't think it's brilliantly written, it seems a little bodged together to me... but works fine - not a bad result for a first script If you are new to this problem and are interested in

Re: File Size Script Help - Working Version

2011-12-29 Thread John W. Krahn
Jonathan Harris wrote: Hi Igor Many thanks for your response I have started reviewing the things you said There are some silly mistakes in there - eg not using closedir It's a good lesson in script vigilance I found the part about opening the file handle particularly interesting I had no

Re: File Size Script Help - Working Version

2011-12-29 Thread Jonathan Harris
On Thu, Dec 29, 2011 at 6:39 PM, John W. Krahn jwkr...@shaw.ca wrote: Jonathan Harris wrote: Hi Igor Many thanks for your response I have started reviewing the things you said There are some silly mistakes in there - eg not using closedir It's a good lesson in script vigilance I found

Re: File Size Script Help - Working Version

2011-12-29 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 12:33 AM, Jonathan Harris jtnhar...@googlemail.comwrote: On Thu, Dec 29, 2011 at 6:39 PM, John W. Krahn jwkr...@shaw.ca wrote: Jonathan Harris wrote: Hi Igor Many thanks for your response I have started reviewing the things you said There are some silly

Re: File Size Script Help - Working Version

2011-12-29 Thread John W. Krahn
Jonathan Harris wrote: On Thu, Dec 29, 2011 at 6:39 PM, John W. Krahnjwkr...@shaw.ca wrote: Igor made a lot of good points. Here are my two cents worth. You are using the File::Find module to traverse the file system and add new files along the way. This _may_ cause problems on some file

Re: File Size Script Help - Working Version

2011-12-29 Thread John W. Krahn
Jonathan Harris wrote: FInally, I was advised by a C programmer to declare all variables at the start of a program to avoid memory issues Is this not necessary in Perl? It is not really necessary in C either. John -- Any intelligent fool can make things bigger and more complex... It takes

re: File Size Script Help

2011-12-19 Thread Jonathan Harris
Hi Perl Pros This is my first call for help I am a totally new, self teaching, Perl hopeful If my approach to this script is simply wrong, please let me know as it will help my learning! The script aims to: 1) Read in a directory either from the command line, or from a default path 2) Produce

Re: File Size Script Help

2011-12-19 Thread Jim Gibson
On 12/19/11 Mon Dec 19, 2011 11:32 AM, Jonathan Harris jtnhar...@googlemail.com scribbled: Hi Perl Pros This is my first call for help I am a totally new, self teaching, Perl hopeful If my approach to this script is simply wrong, please let me know as it will help my learning! The

Re: File Size Script Help

2011-12-19 Thread Shlomi Fish
Hi Jonathan, some comments on your code - both positive and negative. On Mon, 19 Dec 2011 19:32:10 + Jonathan Harris jtnhar...@googlemail.com wrote: Hi Perl Pros This is my first call for help I am a totally new, self teaching, Perl hopeful If my approach to this script is

Re: File Size Script Help

2011-12-19 Thread Jonathan Harris
On Mon, Dec 19, 2011 at 8:08 PM, Jim Gibson jimsgib...@gmail.com wrote: On 12/19/11 Mon Dec 19, 2011 11:32 AM, Jonathan Harris jtnhar...@googlemail.com scribbled: Hi Perl Pros This is my first call for help I am a totally new, self teaching, Perl hopeful If my approach to this

Re: File Size Script Help

2011-12-19 Thread Jonathan Harris
On Mon, Dec 19, 2011 at 8:09 PM, Shlomi Fish shlo...@shlomifish.org wrote: Hi Jonathan, some comments on your code - both positive and negative. On Mon, 19 Dec 2011 19:32:10 + Jonathan Harris jtnhar...@googlemail.com wrote: Hi Perl Pros This is my first call for help I am a