[19793] in Perl-Users-Digest
Perl-Users Digest, Issue: 1988 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 23 06:05:35 2001
Date: Tue, 23 Oct 2001 03:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003831510-v10-i1988@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Oct 2001 Volume: 10 Number: 1988
Today's topics:
Can I read BLOB as stream by DBI (derek chen)
create hashrefs / speed <jens@irs-net.com>
Re: Delete spaces at the end of a string <pne-news-20011023@newton.digitalspace.net>
Re: Delete spaces at the end of a string <pne-news-20011023@newton.digitalspace.net>
Re: Delete spaces at the end of a string <hafner@augusta.de>
Re: Delete spaces at the end of a string <Graham.T.Wood@oracle.com>
Re: Fork messes up parent file handle? <je@brighton.ac.uk>
Re: Fork messes up parent file handle? <je@brighton.ac.uk>
Re: Fork messes up parent file handle? <je@brighton.ac.uk>
Form Validation, detecting a comma <SPG@NoMrtbbrtbrbref.com>
Re: Form Validation, detecting a comma <bernard.el-hagin@lido-tech.net>
Re: Form Validation, detecting a comma <bernard.el-hagin@lido-tech.net>
Re: Form Validation, detecting a comma <goldbb2@earthlink.net>
Re: Form Validation, detecting a comma <SPG@NoMrtbbrtbrbref.com>
Re: Form Validation, detecting a comma <bernard.el-hagin@lido-tech.net>
Re: Form Validation, detecting a comma <bart.lateur@skynet.be>
Re: Good Literature <rob_13@excite.com>
How to get perl working under windows 2000 ? <bmoore@door.net>
Re: How to get perl working under windows 2000 ? <rob_13@excite.com>
MD5 signature - file timestamp? <andrey@flyg.kth.se>
Re: MD5 signature - file timestamp? <goldbb2@earthlink.net>
Net::DNZ zone tranfer to file (Eric Clope)
output problem table format <hugo@fractalgraphics.com.au>
Re: output problem table format <bernard.el-hagin@lido-tech.net>
Re: output problem table format (Logan Shaw)
Re: output problem table format <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Oct 2001 02:48:37 -0700
From: u8526505@ms27.hinet.net (derek chen)
Subject: Can I read BLOB as stream by DBI
Message-Id: <85789064.0110230148.45f96bb5@posting.google.com>
I can have a blob value saved in a file like this
while(($a=$Data->fetchrow_array)){
open A,">a.gif";
binmode(A);
print A $a;
close A;
}
but I'm afraid that the data is too large to be stored in a variable.
Is there any method that I can manipulate the data as stream like
$handle=$Data->fetchrow??
while(<$handle>){
#save data to file
}
BTW,I still can't understand how to use {LongTruncOk} .Is it used for judging
if my data is stored in the variable succesfully?But if it fails,it will break
the while loop,why do I need it ?Thanks.
Derek
------------------------------
Date: Tue, 23 Oct 2001 10:04:46 +0200
From: Jens Luedicke <jens@irs-net.com>
Subject: create hashrefs / speed
Message-Id: <9r38f0$q8u$03$1@news.t-online.com>
hi ...
which code is faster? A benchmark showed no real
differences, with a much larger code snippet. Comments?
$foo = {};
$foo->{bar} = "bla1";
$foo->{baz} = "bla2";
- or -
$foo = {
bar => "bla1",
baz => "bla2",
}
--
Jens Luedicke
jens@irs-net.com
------------------------------
Date: Tue, 23 Oct 2001 08:32:33 +0200
From: Philip Newton <pne-news-20011023@newton.digitalspace.net>
Subject: Re: Delete spaces at the end of a string
Message-Id: <pe3attov6alnihgeh3jrrktcefg7u8d2v0@4ax.com>
On Mon, 22 Oct 2001 22:54:20 GMT, "Ron Hartikka" <ronh@iainc.com> wrote:
> Oh, my. I'm wrong.
Not wrong, just slow. Your first solution will also work, but will spend
useless time on strings that don't end in a space.
Now please don't post TOFU any more :)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Tue, 23 Oct 2001 08:32:33 +0200
From: Philip Newton <pne-news-20011023@newton.digitalspace.net>
Subject: Re: Delete spaces at the end of a string
Message-Id: <cg3attk59pv5jbstklo8182v4aqpqaevpf@4ax.com>
On Mon, 22 Oct 2001 18:28:02 +0500, Robert Sherman
<rsherman@ce.gatech.edu> wrote:
> TGI wrote:
> >
> > How can I delete spaces at the end of a string.
>
> s/\s+$//
Or 1 while s/ $//;
Apocryphal evidence claims that's faster as it can be optimised
differently due to the fixed-length, known-character string and the
end-of-string anchor. Or use sexeger:
$_ = reverse $_; s/^\s+//; $_ = reverse $_;
s/\s+$// is probably the easiest to understand, though.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 23 Oct 2001 09:13:11 +0200
From: Walter Hafner <hafner@augusta.de>
Subject: Re: Delete spaces at the end of a string
Message-Id: <qdfbsiy4yns.fsf@www.ibexnet.de>
TGI <th_gi@hotmail.com> writes:
> How can I delete spaces at the end of a string.
> I tried with
> $string =~ tr/[ ]+$//d and
I assume you know that "tr" doesn't operate on regular expressions, just
like "perldoc perlop" tells you?
Use s/\s+$// instead.
-Walter
------------------------------
Date: Tue, 23 Oct 2001 11:06:12 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Delete spaces at the end of a string
Message-Id: <3BD54113.359B81A4@oracle.com>
This is a multi-part message in MIME format.
--------------6F9C619CBE9485C55B0E709D
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
TGI wrote:
> Hi
>
> How can I delete spaces at the end of a string.
> I tried with
> $string =~ tr/[ ]+$//d and
> $string =~ tr/ +$//d
> but these deletes all spaces in the string.
> I want only delete the spaces at the end.
>
> Tom
Use s///, not tr///, tr works on single characters, s works on strings.
$string =~ s/\s+$//;
Use \s in preference to a space as it matches all white space characters
(space, tab, newline).
Graham Wood
--------------6F9C619CBE9485C55B0E709D
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------6F9C619CBE9485C55B0E709D--
------------------------------
Date: Tue, 23 Oct 2001 09:12:01 +0100
From: John English <je@brighton.ac.uk>
Subject: Re: Fork messes up parent file handle?
Message-Id: <3BD52651.C2860FEB@brighton.ac.uk>
"John W. Krahn" wrote:
>
> John English wrote:
> >
> > Chris Fedde wrote:
> > >
> > > You might create the smallest reasonable bit of code that exhibits
> > > the problem you are seeing and try posting that. The problem is likely to
> > > be in the details.
> >
> > OK, watch this space...
> >
>
> OK, but how long? I want to move on to the next message. Please hurry!
:-)
Here it is: this script reads a file whose name is given on the command
line and creates a child process for each line read. The parent process
echoes the input to STDERR, the child process output goes to STDOUT (so
that you can separate the two). It works fine on Perl 5.6.0 under Linux
(a vanilla Red Hat 7.1 install) but goes mad on Perl 5.6.1 under either
Solaris 6 or 8. It also goes mad with 5.6.1 under Windows, but I expected
that... :-)
----CUT HERE----
$file = $ARGV[0];
$kids = 0;
$SIG{CHLD} = sub { wait; $kids--; };
open CFG, $file or die "Can't open $file: $!\n";
while (<CFG>) {
print STDERR "Parent: $_";
$pid = fork;
if ($pid) { # parent: increment child count
$kids++;
}
elsif (defined($pid)) { # child: process and exit loop
&child_process;
last;
}
else { # something went wrong!
die "Failed to create child: $!\n";
}
}
close CFG;
exit(0);
sub child_process { print "Child $$: $kids\n"; }
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.comp.it.bton.ac.uk/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Tue, 23 Oct 2001 09:23:01 +0100
From: John English <je@brighton.ac.uk>
Subject: Re: Fork messes up parent file handle?
Message-Id: <3BD528E5.4265C73C@brighton.ac.uk>
Mark Jason Dominus wrote:
>
> In article <3BD45F1C.AD56528@brighton.ac.uk>,
> John English <je@brighton.ac.uk> wrote:
> >Thanks. This is presumably the root cause of the problem, but I'm
> >still baffled because the child doesn't access the file handle at
> >all.
>
> It may be a bug in Perl. Other folks have reported problems that may
> be similar, but unfortunately nobody's been able to pin it down well
> enough to fix it.
I've now posted a stripped-down version of the script elsewhere in
this thread. It works fine under Linux (Perl 5.6.0 or 5.6.1), fails
under Solaris 8 (Perl 5.6.1) and Solaris 6 (5.6.0 or 5.6.1), also
under Windows (Perl 5.6.1).
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.comp.it.bton.ac.uk/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Tue, 23 Oct 2001 09:31:48 +0100
From: John English <je@brighton.ac.uk>
Subject: Re: Fork messes up parent file handle?
Message-Id: <3BD52AF4.82056258@brighton.ac.uk>
Joe Schaefer wrote:
> Actually PerlIO is probably irrelevant. It may just be a solaris
> issue with 5.6.1- see if you can reproduce the problem listed here:
>
> http://archive.develooper.com/perl5-porters@perl.org/msg65856.html
>
> (It seems to be OK for linux).
This looks like the same problem. Thanks.
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.comp.it.bton.ac.uk/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Tue, 23 Oct 2001 09:04:47 +0100
From: "Stephen Graham" <SPG@NoMrtbbrtbrbref.com>
Subject: Form Validation, detecting a comma
Message-Id: <Lv9B7.62981$sF.5765693@news2-win.server.ntlworld.com>
Hi All,
I have a Perl script that checks the validity of an email address. However
it doesn't seem to invalidate a 'comma', causing an incorrectly entered
email to parse as two emails.
i.e. "a,name@company.com" is getting parsed as "a@servername" and
"name@company.com".
I want to invalidate such an entry. I'm using this subroutine...
sub valid_emailaddress
{
$checkmail = $fields{'form_email'};
if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$checkmail !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{return 0;}
else
{return 1;}
}
My knowledge of Perl ends with the above if statement. What should I change
such that it returns 0 if the address contains a comma ','.
Thanks,
SG
------------------------------
Date: 23 Oct 2001 08:14:34 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Form Validation, detecting a comma
Message-Id: <slrn9ta9bg.24g.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 23 Oct 2001 09:04:47 +0100, Stephen Graham <SPG@NoMrtbbrtbrbref.com>
wrote:
> Hi All,
>
> I have a Perl script that checks the validity of an email address. However
> it doesn't seem to invalidate a 'comma', causing an incorrectly entered
> email to parse as two emails.
>
> i.e. "a,name@company.com" is getting parsed as "a@servername" and
> "name@company.com".
>
> I want to invalidate such an entry. I'm using this subroutine...
>
> sub valid_emailaddress
> {
> $checkmail = $fields{'form_email'};
> if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
> $checkmail !~
> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
> {return 0;}
> else
> {return 1;}
> }
>
> My knowledge of Perl ends with the above if statement. What should I change
> such that it returns 0 if the address contains a comma ','.
return 0 if /,/;
Cheers,
Bernard
------------------------------
Date: 23 Oct 2001 08:15:50 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Form Validation, detecting a comma
Message-Id: <slrn9ta9ds.24g.bernard.el-hagin@gdndev25.lido-tech>
On 23 Oct 2001 08:14:34 GMT, Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
wrote:
> On Tue, 23 Oct 2001 09:04:47 +0100, Stephen Graham <SPG@NoMrtbbrtbrbref.com>
> wrote:
>> Hi All,
>>
>> I have a Perl script that checks the validity of an email address. However
>> it doesn't seem to invalidate a 'comma', causing an incorrectly entered
>> email to parse as two emails.
>>
>> i.e. "a,name@company.com" is getting parsed as "a@servername" and
>> "name@company.com".
>>
>> I want to invalidate such an entry. I'm using this subroutine...
>>
>> sub valid_emailaddress
>> {
>> $checkmail = $fields{'form_email'};
>> if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
>> $checkmail !~
>> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
>> {return 0;}
>> else
>> {return 1;}
>> }
>>
>> My knowledge of Perl ends with the above if statement. What should I change
>> such that it returns 0 if the address contains a comma ','.
>
>
> return 0 if /,/;
Sorry, that should be:
return 0 if $checkmail =~ /,/;
Cheers,
Bernard
------------------------------
Date: Tue, 23 Oct 2001 04:51:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Form Validation, detecting a comma
Message-Id: <3BD52F8F.B18ACFA2@earthlink.net>
Stephen Graham wrote:
>
> Hi All,
>
> I have a Perl script that checks the validity of an email address.
The correct way to identify valid email addresses is to match them
against the specification in RFC 2822 [which superceeds RFC 822].
Annoyingly, parts of it are recursive:
ccontent = ctext / quoted-pair / comment
comment = "(" *([FWS] ccontent) [FWS] ")"
So it can't be parsed by a simple regular expression.
Perhaps someone will write a module which uses Parse::RecDescent to
determine if something is a valid email address?
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 23 Oct 2001 10:25:15 +0100
From: "Stephen Graham" <SPG@NoMrtbbrtbrbref.com>
Subject: Re: Form Validation, detecting a comma
Message-Id: <eHaB7.63569$sF.5834339@news2-win.server.ntlworld.com>
Hi Bernard,
I'm using
sub valid_emailaddress
{
$checkmail = $fields{'form_email'};
if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$checkmail !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{return 0;}
elsif ($checkmail =~ /,/)
{return 0;}
else
{return 1;}
}
It seems to work fine,
Thanks!
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn9ta9ds.24g.bernard.el-hagin@gdndev25.lido-tech...
> >>
> >> sub valid_emailaddress
> >> {
> >> $checkmail = $fields{'form_email'};
> >> if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
> >> $checkmail !~
> >> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
> >> {return 0;}
> >> else
> >> {return 1;}
> >> }
> >>
> >> My knowledge of Perl ends with the above if statement. What should I
change
> >> such that it returns 0 if the address contains a comma ','.
> >
> >
> > return 0 if /,/;
>
>
> Sorry, that should be:
>
>
> return 0 if $checkmail =~ /,/;
>
>
> Cheers,
> Bernard
------------------------------
Date: 23 Oct 2001 09:34:52 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Form Validation, detecting a comma
Message-Id: <slrn9tae22.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 23 Oct 2001 10:25:15 +0100, Stephen Graham <SPG@NoMrtbbrtbrbref.com>
wrote:
> "Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
> news:slrn9ta9ds.24g.bernard.el-hagin@gdndev25.lido-tech...
>> >>
>> >> sub valid_emailaddress
>> >> {
>> >> $checkmail = $fields{'form_email'};
>> >> if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
>> >> $checkmail !~
>> >> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
>> >> {return 0;}
>> >> else
>> >> {return 1;}
>> >> }
>> >>
>> >> My knowledge of Perl ends with the above if statement. What should I
> change
>> >> such that it returns 0 if the address contains a comma ','.
>> >
>> >
>> > return 0 if /,/;
>>
>>
>> Sorry, that should be:
>>
>>
>> return 0 if $checkmail =~ /,/;
>
> Hi Bernard,
>
> I'm using
>
> sub valid_emailaddress
> {
> $checkmail = $fields{'form_email'};
> if ($checkmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
> $checkmail !~
> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
> {return 0;}
> elsif ($checkmail =~ /,/)
> {return 0;}
> else
> {return 1;}
> }
>
> It seems to work fine,
But remember that, as Benjamin G. stated, you're not really
checking for valid e-mail addresses with your regex. Maybe for your
purposes the above is enough, but then again, maybe not.
Cheers,
Bernard
------------------------------
Date: Tue, 23 Oct 2001 09:48:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Form Validation, detecting a comma
Message-Id: <tpeattcb4k44urn1ph51kcu87oaideehft@4ax.com>
Benjamin Goldberg wrote:
>Perhaps someone will write a module which uses Parse::RecDescent to
>determine if something is a valid email address?
It's been done (by Abigail): RFC::RFC822::Address
--
Bart.
------------------------------
Date: Tue, 23 Oct 2001 06:50:30 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Good Literature
Message-Id: <Xns91431CCEE793Brock13com@64.8.1.226>
Dave Cross <news:3BD47402.3B1BDFDB@dave.org.uk>:
> Uri Guttman wrote:
>
>> now why couldn't this have happened BEFORE it was published?
>> why don't these authors and publishers get competent tech
>> reviewers? [...]
> I don't have all the answers, but here's my current theory.
>
> The people who buy these books aren't "programmers" in any
> sense of the word. They simply want to put guestbooks and hit
> counters on their web pages. That has to be easy right? Because
> web stuff is _always_ easy. Bill Gates said so.
Hm, I guess a tiny bit of programming in C and gbasic clued me in
just enough to buy Learning Perl and Perl Cookbook when I wanted to
write a guestbook:-) Thankfully, I got a good introduction to Perl.
Perhaps it was those Books for Dummies that made many people think
that learning something technical should be simple. I love that
yellow and black Cliff's Notes appeal.
> [...] Liz Castro's "Perl and CGI for the WWW" is a
> lot better than it was, but it's still not a great book. All of
> the other "Learn Perl and CGI" books are rubbish.
I have one (c)1999 that I don't think mentions the CGI module or
the like. Personally I think it'd be easier to point at the CGI
module as a black box and show how to use it than to fiddle with
the raw CGI exchange.
> The three good Perl/CGI books that we have (the mouse book, the
> spiky ball book and Lincoln's guide to CGI.pm) fail to appeal
> to beginners. In fact, tey all assume a certain level of Perl
> knowledge.
Well, I can identify 2 out of 3 but what is the 'spiky ball book'?
As a beginner I must admit those were not my first considerations.
> The only solution that I can see is that _someone_ is going to
> have to write a respectable Perl/CGI for beginners book.
>
> Any volunteers?
I'd do it but don't know near enough Perl, probably not enough CGI
either. {crawling back under my rock now...}
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Tue, 23 Oct 2001 06:03:40 GMT
From: "Brett L. Moore" <bmoore@door.net>
Subject: How to get perl working under windows 2000 ?
Message-Id: <0L7B7.13565$IR4.8342536@news1.denver1.co.home.com>
Hi,
I am trying to get a cgi script to work under win 2K. After scouring the
web, I have tried everything: registry edits, directory properties, etc. No
matter what I try, the script text is dumped to the browser, rather than
executing.
Any ideas?
TIA, Brett
------------------------------
Date: Tue, 23 Oct 2001 07:00:41 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: How to get perl working under windows 2000 ?
Message-Id: <Xns91431E8892621rock13com@64.8.1.226>
Brett L. Moore
<news:0L7B7.13565$IR4.8342536@news1.denver1.co.home.com>:
> I am trying to get a cgi script to work under win 2K. After
> scouring the web, I have tried everything: registry edits,
> directory properties, etc. No matter what I try, the script
> text is dumped to the browser, rather than executing.
>
> Any ideas?
Sounds like a server configuration issue. Does the script work from
a command prompt? If its Apache refer to RTFM (or the httpd.conf)
and it should tell you how to get it working.
Incidentally, a server issue should be asked in a group for
whatever server you happen to be running.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Tue, 23 Oct 2001 10:39:24 +0200
From: Andrey Shipsha <andrey@flyg.kth.se>
Subject: MD5 signature - file timestamp?
Message-Id: <3BD52CBC.C70BDC4D@flyg.kth.se>
Hello,
I am using Digest::MD5 qw(md5) module in my perl code to check for a MD5
signature of some files on remote hosts. I get the signtatures as short
strings containing a number of symbols which tell me nothing.
I wonder whether I could get a time/date stamp from the computed MD5
signatures? If not, what are other tools/means in Perl to do that? I
don't have a direct access to the files on remote hosts, so I can't
simply see their modification time/date.
Cheers,
/Andrey.
------------------------------
Date: Tue, 23 Oct 2001 05:47:08 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: MD5 signature - file timestamp?
Message-Id: <3BD53C9C.6D8B9AEE@earthlink.net>
Andrey Shipsha wrote:
>
> Hello,
>
> I am using Digest::MD5 qw(md5) module in my perl code to check for a
> MD5 signature of some files on remote hosts. I get the signtatures as
> short strings containing a number of symbols which tell me nothing.
>
> I wonder whether I could get a time/date stamp from the computed MD5
> signatures?
Not really, since the time/date probably did not go into the signature.
The way these things work is you take all the data in the file, and feed
it into the MD5 algorithm, and it spits back a gobldeygook binary
string, which your software then turns into a gobldeygook ascii string.
The only thing you can know is that it is highly unlikely that two
different files going into MD5 will produce the same gobldeygook strings
when coming out.
> If not, what are other tools/means in Perl to do that? I don't have a
> direct access to the files on remote hosts, so I can't simply see
> their modification time/date.
What you can do is keep a database [DB_File or something] which has
filenames as keys, and [md5 signature, date] pairs as values. When you
first fill up the database, use todates date as the date for all the
files. Have a program regularly connect to the remote machine and ask
for the md5 signatures. Then, for each (filename, signature) pair, look
up the filename in your database, and see if what you just got is the
same as the signature you already had. If they are different, then
store the current date; if they are the same, leave it alone.
This is sorta like repeatedly asking, "Are you the same as last time I
asked," and writing down the times when you got a 'no' answer. The time
granularity is however often you connect and ask.
--
Klein bottle for rent - inquire within.
------------------------------
Date: 22 Oct 2001 21:21:03 -0700
From: cell_x@hotmail.com (Eric Clope)
Subject: Net::DNZ zone tranfer to file
Message-Id: <bc06032.0110222021.68bfb0b1@posting.google.com>
Good evening,
I would like to create a simple program that dumps a succesful zone
transfer to a file. I can get the command like dump on my shell but I
would like it to go to a file. I do not want to use "dig @ axfr >
file"... just good net::dns.
# basic frame i think
use Net::DNS;
$res = new Net::DNS::Resolver;
$res->nameservers("ns.foo.com");
@zone = $res->axfr("foo.com");
foreach $rr (@zone) {
$rr->print;
}
I tried the following within the above script but I either get 111 or
hash code dumps in my file.
open (DOMAIN, "+>zone dump");
print $rr-print;
close (DOMAIN);
Thanks for your time... =)
eric
------------------------------
Date: Tue, 23 Oct 2001 16:31:10 +0800
From: hugo <hugo@fractalgraphics.com.au>
Subject: output problem table format
Message-Id: <3BD52ACE.68E10389@fractalgraphics.com.au>
Hi
I have a problem with writing out an array in table format.
I have an array of values where, for a certain repeat count, the values
are related, ie
@text (1, 2, 3, 4, 1a, 2a, 3a, 4a, 1b, 2b, 3b, 4b )
Here the count is 4 as 1 is related to 1a and 1b, 2 to 2a and 2b etc.
I would like to draw this table like this:
1 1a 1b
2 2a 2b
3 3a 3b
4 4a 4b
In terms or array numbers I have to write out the values in the
following sequence as output to a file is done left to right, line per
line:
1 5 9
2 6 10
3 7 11
4 8 12
I do know the value of the repeat count (which in this case is 4, but
that can vary) and I do know the total number of values in my array as
well of course.
How do I do this?
Any help greatly appreciated.
Thanks
Hugo
--
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics
57 Havelock Street, West Perth 6005
Western Australia 6009
Tel: +618 9211 6000
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au
------------------------------
Date: 23 Oct 2001 08:45:04 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: output problem table format
Message-Id: <slrn9tab4m.24g.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 23 Oct 2001 16:31:10 +0800, hugo <hugo@fractalgraphics.com.au> wrote:
> Hi
>
> I have a problem with writing out an array in table format.
>
> I have an array of values where, for a certain repeat count, the values
> are related, ie
>
> @text (1, 2, 3, 4, 1a, 2a, 3a, 4a, 1b, 2b, 3b, 4b )
>
> Here the count is 4 as 1 is related to 1a and 1b, 2 to 2a and 2b etc.
>
> I would like to draw this table like this:
>
> 1 1a 1b
> 2 2a 2b
> 3 3a 3b
> 4 4a 4b
>
> In terms or array numbers I have to write out the values in the
> following sequence as output to a file is done left to right, line per
> line:
>
> 1 5 9
> 2 6 10
> 3 7 11
> 4 8 12
>
> I do know the value of the repeat count (which in this case is 4, but
> that can vary) and I do know the total number of values in my array as
> well of course.
>
> How do I do this?
--------------------
#!/usr/bin/perl
use warnings;
use strict;
my @text = qw( 1 2 3 4 1a 2a 3a 4a 1b 2b 3b 4b );
my $count = 4; # change count as needed
foreach (0 .. @text){
if( defined ( $text[$_ + 2*$count] ) ){
print "$text[$_] $text[$_ + $count] $text[$_ + 2*$count]\n";
}
}
--------------------
Cheers,
Bernard
------------------------------
Date: 23 Oct 2001 04:14:23 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: output problem table format
Message-Id: <9r3cdf$4h8$1@charity.cs.utexas.edu>
In article <3BD52ACE.68E10389@fractalgraphics.com.au>,
hugo <hugo@fractalgraphics.com.au> wrote:
>I have a problem with writing out an array in table format.
>
>I have an array of values where, for a certain repeat count, the values
>are related, ie
>
>@text (1, 2, 3, 4, 1a, 2a, 3a, 4a, 1b, 2b, 3b, 4b )
>
>Here the count is 4 as 1 is related to 1a and 1b, 2 to 2a and 2b etc.
>
>I would like to draw this table like this:
>
>1 1a 1b
>2 2a 2b
>3 3a 3b
>4 4a 4b
Here's one way:
@text = qw{ 1 2 3 4 1a 2a 3a 4a 1b 2b 3b 4b };
# figure out our dimensions
$columns = 3;
$rows = @text / $columns;
# compute all the offsets in advance
@offsets = map ($rows * $_, 0 .. $columns - 1);
# print each row
for (my $row = 0; $row < $rows; $row++)
{
print join (
"\t",
map ($text[$row+$_], @offsets)
),
"\n";
}
In this example, @offsets will be (0, 4, 8), so when you print row 0,
you print array elements 0+0, 0+4, and 0+8. Then, when you do row 1,
you print array elements 1+0, 1+4, and 1+8. And so on.
Hope that helps.
- Logan
P.S.: I think you meant to post to
comp.lang.perl.modules rather than
comp.perl.lang.modules, but that's
probably better since it's not
really a module questino.
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Tue, 23 Oct 2001 05:30:37 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: output problem table format
Message-Id: <3BD538BD.FC937985@earthlink.net>
hugo wrote:
>
> Hi
>
> I have a problem with writing out an array in table format.
>
> I have an array of values where, for a certain repeat count, the
> values are related, ie
>
> @text (1, 2, 3, 4, 1a, 2a, 3a, 4a, 1b, 2b, 3b, 4b )
>
> Here the count is 4 as 1 is related to 1a and 1b, 2 to 2a and 2b etc.
>
> I would like to draw this table like this:
>
> 1 1a 1b
> 2 2a 2b
> 3 3a 3b
> 4 4a 4b
my @text = qw(1 2 3 4 1a 2a 3a 4a 1b 2b 3b 4b);
my $columns = 3;
my @columns = map [splice @text, 0, @text/-$_], -$columns .. -1;
for( 1 .. @{$columns[0]} ) {
print join(" ", map shift @$_, @columns ), "\n";
}
--
Klein bottle for rent - inquire within.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1988
***************************************