Shlomi Fish writes:
>> > But if the size hasn't changed, then you still need to check something
>> > else. You can do another light check, or decide to do the heavy one.
>> >
>> > This is also important because a hash-value is only a fingerprint, so
>> > different files have (a small chance on ha
Jim Gibson writes:
> Some comments on your code:
>
> 1. Rather than doing this:
>
> while ( <$curridx>) { chomp $_; my $current_file = $_;
>
> you should do this:
>
> while ( my $current_file = <$curridx> ) { chomp($current_file);
Ah cool :) I really didn't like the way I did that, this is
Jim Gibson writes:
> On Jun 13, 2013, at 1:30 PM, lee wrote:
>
>> In my application, my estimate is that there will be a set of around
>> 100--150 files. Once a file is closed and reported one last time, it
>> doesn't need to be considered anymore, so the number of relevant files
>> is limited.
On Jun 13, 2013, at 10:57 PM, lee wrote:
> Hi,
>
> so I've done this script now --- my fourth perl script ever --- and
> since I'm getting so much help here, I thought I'd post it here. I'm
> sure it could be done much better, it's just plain and simple.
>
> It has one problem: The list of clo
On 14/06/2013 08:02, Shlomi Fish wrote:
On Thu, 13 Jun 2013 22:51:24 +0200
lee wrote:
How likely is it that the hash is the same though the file did change?
Well, if you take SHA-256 for example, then its hash has 256 bits so you have a
chance of 1 / (2**256) that two non-identical byte vec
Hi Lee,
On Thu, 13 Jun 2013 22:51:24 +0200
lee wrote:
> "Dr.Ruud" writes:
>
> > On 12/06/2013 10:27, lee wrote:
> >
> >> File sizes do not reliably indicate whether a file has been modified or
> >> not.
> >
> > If the file size has changed, then your file has changed. That is 100%
> > reliable
Hi,
so I've done this script now --- my fourth perl script ever --- and
since I'm getting so much help here, I thought I'd post it here. I'm
sure it could be done much better, it's just plain and simple.
It has one problem: The list of closed files can grow indefinitely, and
since the script che
Hi David,
On Thu, 13 Jun 2013 21:30:00 -0700
David Christensen wrote:
> On 06/13/13 01:41, Shlomi Fish wrote:
> > 1. You're lacking strict and warnings:
> > 2. You're looping using $_ :
> > 3. You're using md5_hex by slurping the contents of the file into memory,
> > 4. read_file was not explict
On 06/13/13 01:41, Shlomi Fish wrote:
1. You're lacking strict and warnings:
2. You're looping using $_ :
3. You're using md5_hex by slurping the contents of the file into memory,
4. read_file was not explictly imported from File::Slurp:
Both the Perl Cookbook and Programming Perl are showing the
On Jun 13, 2013, at 1:30 PM, lee wrote:
> In my application, my estimate is that there will be a set of around
> 100--150 files. Once a file is closed and reported one last time, it
> doesn't need to be considered anymore, so the number of relevant files
> is limited. Each file is only about 2k
"Dr.Ruud" writes:
> On 12/06/2013 11:33, lee wrote:
>> Jim Gibson writes:
>>> On Jun 11, 2013, at 9:44 PM, lee wrote:
>
I've been googling for examples of how to create a sha-2 sum of a
file in perl without success. What I'm looking for is something
like:
$hash = cre
"Dr.Ruud" writes:
> On 12/06/2013 10:27, lee wrote:
>
>> File sizes do not reliably indicate whether a file has been modified or
>> not.
>
> If the file size has changed, then your file has changed. That is 100%
> reliable, and is a quick and cheap check.
It works only one way: different size --
Jim Gibson writes:
> On Jun 13, 2013, at 10:51 AM, lee wrote:
>> + When I create files with lines like "filename:size:mtime" or
>> "filename:hash", is there something built in to read a syntax like
>> this into, let's say, an array like "my @fileinfo;" with $fileinfo[0]
>> being the file name,
Jim Gibson writes:
> On Jun 13, 2013, at 11:33 AM, lee wrote:
>
>> Shlomi Fish writes:
>>
>>
>> our $fh;
>
> Why the our?
I've been reading that you need to declare variables before using them
when you use strict. A "my $fh;" would probably suffice.
>>>
>>> You ca
Jim Gibson wrote:
On Jun 13, 2013, at 10:51 AM, lee wrote:
+ Is "print" and "printf" pretty much the same thing implementation
wise? I'm wondering if "printf" might involve more overhead so it
might be less efficient, depending on what you're doing.
They are pretty much the same. print
On Jun 13, 2013, at 11:33 AM, lee wrote:
> Shlomi Fish writes:
>
>
> our $fh;
Why the our?
>>>
>>> I've been reading that you need to declare variables before using them
>>> when you use strict. A "my $fh;" would probably suffice.
>>
>> You can do the declaration during the op
On Jun 13, 2013, at 10:51 AM, lee wrote:
> #!/bin/perl
>
> use strict;
> use warnings;
>
> chomp $ARGV[0];
> my @info = (stat ($ARGV[0] ) );
>
> printf("%s: %d bytes, %d mtime\n", $ARGV[0], $info[7], $info[9] );
>
>
> Some more questions to this:
>
>
> + Is "chomp $ARGV[0];" even allowed?
Shlomi Fish writes:
> Hi Lee,
>
> thanks for replying to the list and for not top posting.
Yvw :) I hate top posting --- only in rare cases, I find it
useful/reasonable. And posting the solution here might help others.
>> >> #!/bin/perl
>> >
>> > Is your Perl at /bin? Shouldn't it be in /usr/
Jim Gibson writes:
> On Jun 12, 2013, at 2:33 AM, lee wrote:
>
>> Jim Gibson writes:
>>
>>>
>>> The first thing to do would be to check the file size. If the file
>>> size has changed, then the file has been modified. So you will want to
>>> save the file size.
>>
>> The file might be modifie
Hello David,
some comments on your code.
On Wed, 12 Jun 2013 15:53:32 -0700
David Christensen 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
On 12/06/2013 10:27, lee wrote:
File sizes do not reliably indicate whether a file has been modified or
not.
If the file size has changed, then your file has changed. That is 100%
reliable, and is a quick and cheap check.
But if the size hasn't changed, then you still need to check somethin
On 12/06/2013 11:33, lee wrote:
Jim Gibson writes:
On Jun 11, 2013, at 9:44 PM, lee wrote:
I've been googling for examples of how to create a sha-2 sum of a
file in perl without success. What I'm looking for is something
like:
$hash = create_sha2_sum( $filename);
Do you know of any exa
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
Hi Lee,
thanks for replying to the list and for not top posting.
See below for my comments.
On Wed, 12 Jun 2013 17:50:57 +0200
lee wrote:
> Shlomi Fish writes:
>
> > Hi Lee,
> >
> > some comments on your code:
> >
> > On Wed, 12 Jun 2013 11:28:34 +0200
> > lee wrote:
> >
> >> David Christen
Shlomi Fish writes:
>> I've been googling for examples of how to create a sha-2 sum of a file
>> in perl without success. What I'm looking for is something like:
>
> In general, you should not Google for Perl information, because Google tends
> to
> find outdated results. Instead, use MetaCPAN
Shlomi Fish writes:
> Hi Lee,
>
> some comments on your code:
>
> On Wed, 12 Jun 2013 11:28:34 +0200
> lee wrote:
>
>> David Christensen writes:
>>
>> > On 06/11/13 21:44, lee wrote:
>> >> ... what I don't understand is what
>> >> the most efficient way would be to create a sha-2 sum for a fil
James Alton writes:
> What is the reason for checking file hashes once a month? Are you just
> trying to do a basic sys admin task like ensuring system file integrity? No
> sense in reinventing the wheel. Look into tripwire.
> http://www.linuxjournal.com/article/8758
The purpose is to generate m
On Jun 12, 2013, at 2:33 AM, lee wrote:
> Jim Gibson writes:
>
>>
>> The first thing to do would be to check the file size. If the file
>> size has changed, then the file has been modified. So you will want to
>> save the file size.
>
> The file might be modified without changing its size ...
What is the reason for checking file hashes once a month? Are you just
trying to do a basic sys admin task like ensuring system file integrity? No
sense in reinventing the wheel. Look into tripwire.
http://www.linuxjournal.com/article/8758
Cheers,
James
On Wed, Jun 12, 2013 at 2:27 AM, lee wrot
Hi Lee,
some comments on your code:
On Wed, 12 Jun 2013 11:28:34 +0200
lee wrote:
> David Christensen writes:
>
> > On 06/11/13 21:44, lee wrote:
> >> ... what I don't understand is what
> >> the most efficient way would be to create a sha-2 sum for a file.
> >
> > Have you considered Digest?
Pritish Pattanaik writes:
> Hello Lee,
>
> use Digest::MD5 module I believe solve your problem, But you can
> incorporate other Perl modules to achieve your task.
>
> Things I would consider for this task :
>
> 1. Scripts checks on file/directory on every ? seconds
once a month
> 2. I should no
David Christensen writes:
> On 06/11/13 21:44, lee wrote:
>> ... what I don't understand is what
>> the most efficient way would be to create a sha-2 sum for a file.
>
> Have you considered Digest?
>
> http://perldoc.perl.org/Digest.html
Yes, I've been looking at descriptions like that and I
Jim Gibson writes:
> On Jun 11, 2013, at 9:44 PM, lee wrote:
>> I've been googling for examples of how to create a sha-2 sum of a
>> file in perl without success. What I'm looking for is something
>> like:
>>
>> $hash = create_sha2_sum( $filename);
>>
>> Do you know of any examples I could l
Hi Lee,
On Wed, 12 Jun 2013 06:44:19 +0200
lee wrote:
> Hi,
>
> what I'm trying to do is create a list of sha-2 sums of files the names
> of which are stored in a file. The purpose is to verify from time to
> time whether any of the listed files have been modified or not in the
> meantime.
>
Hello Lee,
use Digest::MD5 module I believe solve your problem, But you can
incorporate other Perl modules to achieve your task.
Things I would consider for this task :
1. Scripts checks on file/directory on every ? seconds
2. I should not bother about access time.
3.your script need to calculat
On 06/11/13 21:44, lee wrote:
... what I don't understand is what
the most efficient way would be to create a sha-2 sum for a file.
Have you considered Digest?
http://perldoc.perl.org/Digest.html
HTH,
David
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional comman
On Jun 11, 2013, at 9:44 PM, lee wrote:
> Hi,
>
> what I'm trying to do is create a list of sha-2 sums of files the names
> of which are stored in a file. The purpose is to verify from time to
> time whether any of the listed files have been modified or not in the
> meantime.
>
> So I can read
Hi,
what I'm trying to do is create a list of sha-2 sums of files the names
of which are stored in a file. The purpose is to verify from time to
time whether any of the listed files have been modified or not in the
meantime.
So I can read the list of file names; what I don't understand is what
t
38 matches
Mail list logo