[24038] in Perl-Users-Digest
Perl-Users Digest, Issue: 6235 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 8 21:05:41 2004
Date: Mon, 8 Mar 2004 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Mar 2004 Volume: 10 Number: 6235
Today's topics:
Re: /dev/pts/x, /proc/x/fd, reading stdout, writing std <nospam@nospam9.se>
Re: /dev/pts/x, /proc/x/fd, reading stdout, writing std (Anno Siegel)
Re: Calling a remote ASP script from my Perl Script -li <matthew.garrish@sympatico.ca>
Re: Changing output <shotoku.taishi@virgin.net>
Re: CPAN shell complains about MD5 <carpenter@construction.net>
function override (Zhao Wu)
Re: Is it possible to impose a timeout on <>? <pkent77tea@yahoo.com.tea>
Re: MS SQL 2000 anonymous@coolgroups.com
Re: MS SQL 2000 anonymous@coolgroups.com
Re: MS SQL 2000 <usenet@morrow.me.uk>
Re: MS SQL 2000 <734562323@yahoo.de>
Re: Need help with Undeliverable Emails <whoknows@NoSpamPLZ.net>
Re: open (FAILEHANDLER, ">>$filename") what is the ron <vilmos@vilmos.org>
Re: open (FAILEHANDLER, ">>$filename") what is the ron <kkeller-usenet@wombat.san-francisco.ca.us>
Ordering large files (in perl?) (Oeln)
Re: Ordering large files (in perl?) (Walter Roberson)
Re: Ordering large files (in perl?) <komsbomb@hotmail.com>
pack/unpack question (WA Support)
Re: pack/unpack question <tassilo.parseval@rwth-aachen.de>
Re: pack/unpack question <gnari@simnet.is>
parsing smime files using Perl (Novice)
Re: parsing smime files using Perl <zoooz@gmx.de>
Re: scheduling a perl script <jgibson@mail.arc.nasa.gov>
Re: Statistics for comp.lang.perl.misc (Sam Holden)
Re: Unwanted newline or eol between fields (Juergen Kuehne)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 08 Mar 2004 19:17:24 GMT
From: Andreas Persson <nospam@nospam9.se>
Subject: Re: /dev/pts/x, /proc/x/fd, reading stdout, writing stdin, not with open3
Message-Id: <pan.2004.03.08.19.18.10.582450@nospam9.se>
On Mon, 08 Mar 2004 17:20:12 +0000, Anno Siegel wrote:
[...]
> "open(?)" ... "created/using/virtual_console" ...
>
> These slash-separated ambiguities usually mean that the poster hasn't
> thought enough about the problem to have a good idea what is needed and
> hopes that Usenet will supply the right question *and* the answer. I
> find that annoying.
Oh, im truly sorry to have annoyed you.
i thought "..and read its stdout and let me write to its stdin?" was
clear enough.
the "open(?)" was typed because i have no idea if i can use the built in
open operator.
>> is it possible to use /proc/$pid/fd/x in some way?
>
> "...in some way"? In what way do you *want* to use it? It's your job
> to tell us.
"..and read its stdout and let me write to its stdin?"
> How is running open3 bad, and how is it worse to to it all day than
> to do it once?
so i can make changes to the perl script and restart it without shutting
down the server program.
i wish to apologise to you Anno, i thought i was clear enough.
/best wishes Andreas
------------------------------
Date: 8 Mar 2004 20:17:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: /dev/pts/x, /proc/x/fd, reading stdout, writing stdin, not with open3
Message-Id: <c2ikd2$ce$1@mamenchi.zrz.TU-Berlin.DE>
Andreas Persson <nospam@nospam9.se> wrote in comp.lang.perl.misc:
> On Mon, 08 Mar 2004 17:20:12 +0000, Anno Siegel wrote:
> [...]
> > "open(?)" ... "created/using/virtual_console" ...
> >
> > These slash-separated ambiguities usually mean that the poster hasn't
> > thought enough about the problem to have a good idea what is needed and
> > hopes that Usenet will supply the right question *and* the answer. I
> > find that annoying.
>
> Oh, im truly sorry to have annoyed you.
>
> i thought "..and read its stdout and let me write to its stdin?" was
> clear enough.
So "its" refers to the process that is using the file you want to open.
It seemed to refer to the file, but that makes no sense.
> the "open(?)" was typed because i have no idea if i can use the built in
> open operator.
Well, to "open" a file is a generic action, not bound to an operator called
"open". If you're not sure if you want to open it, you're not sure if
you want a file handle (or its equivalent in another language). That
leaves one speculating what else you might want of the file.
> >> is it possible to use /proc/$pid/fd/x in some way?
> >
> > "...in some way"? In what way do you *want* to use it? It's your job
> > to tell us.
>
> "..and read its stdout and let me write to its stdin?"
Again, "stdout" and "stdin" seem to refer to the file. That makes no sense,
files don't have them, processes do.
> > How is running open3 bad, and how is it worse to to it all day than
> > to do it once?
>
> so i can make changes to the perl script and restart it without shutting
> down the server program.
What Perl script? This is the first time you mention a Perl script.
What part does it play in this drama? And which is the server program?
The one whose IO you want to hijack? An why must it keep running?
Look, I think you have what we call an XY problem. Meaning, you want
to do X, and you think the only way to do it is Y. So you ask how to
do Y. But if Y isn't the right way of doing X, we're stuck, as we seem
to be.
There is only one way out, you tell us what the real problem is. Apparently
you want to make the services of some program (whose properties we don't
know, they matter) available to an unspecified group of users. Now give
us the relevant detail, and maybe we can work out a solution.
Anno
------------------------------
Date: Mon, 8 Mar 2004 18:52:14 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Calling a remote ASP script from my Perl Script -libwww?
Message-Id: <GG73c.11937$6y1.472095@news20.bellglobal.com>
"Chris" <ceo@nospan.on.net> wrote in message
news:0R%2c.22009$3m4.6006@newssvr31.news.prodigy.com...
> Dave Smithz wrote:
> >
> > I have a Perl script that needs to process a web form. But also I then
need
> > to send some of that data to a third party ASP script and interpret the
> > returned results.
> >
> > How can I do this.
> >
>
> Form filled in -> Submit -> Form fields returned to Perl -> Perl
> processes information -> Redirects to ASP passing information to ASP page.
>
Take another look at his question. He's not looking for a redirect but to
call the script on a different server and process the returned page/data.
LWP not CGI...
Matt
------------------------------
Date: Mon, 8 Mar 2004 20:34:25 -0000
From: "Euro Millions" <shotoku.taishi@virgin.net>
Subject: Re: Changing output
Message-Id: <c2ilqs$1e6$1@news5.svr.pol.co.uk>
Thank you all for your replies. My sincere apologies for not getting back to
you earlier but I was away over the weekend. I will put your suggestions
into practice and will let you know hw I get on. :-)
Okay, what I really want to do?
I thought that I might be able to put together a little Perl program to help
me automate writing my weekly report. Maybe you can think of a better way
than what I had in mind?
The language thing was just an example for me to get started, but this is
what I had in mind:
First I wanted to put all the info into a reader friendly excel file e.g.
date, tasks completed, tasks planned for next week . This file would be
saved into a csv file. Subsequently I have to change the format which I can
import into a word template using the mail merge facility. Too complicated?
The problem about using mail merge is that in order to get it to work I need
all the info to be stored into two lines - one title line and the other line
to contain all the data. So I wanted this particular perl script to
translate my reader friendly excel file (saved into a csv text file) into a
format which can be understood by the mail merge program. It might be a
little tedious to put together but in the end I am sure it would be a time
saving exercise.
Kind Regards
Mike
"Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
news:Pine.A41.4.58.0403052114580.17250@ginger.libs.uga.edu...
> On Fri, 5 Mar 2004, Euro Millions wrote:
> > What I would like to do is simple (that is if you know it)
> >
> > I have a CSV text file (comma separated file) which contains the
following
> > info:
> >
> > Language, Greeting,
> > English, Hello,
> > German, Hallo,
> > Spanish, Hola,
> > Japanese, Konnichiwa,
> >
> > I would like Perl to create an output file which looks as follows:
> >
> > Language,Language2, Language3, Langauge4, Greeting,Greeting2, Greeting3,
> > Greeting4
> > English, German, Spanish, Japanese, Hello, Hallo, Hola, Konnichiwa
>
> Okay, now tell us what you REALLY want to do. :-)
>
> Obviously, you don't really have that file, because writing a program for
> that purpose just doesn't make sense. So, do you really have a file that
> contains dozens of languages? Is "Greeting" always "Hello", not "Good
> morning", "G'day", "'Sup"? I assume your list contains other things, like
> "Thank you", "Please", etc.
>
> The question as it stands is so trivial that I'm compelled to think you're
> leaving out the parts that matter.
>
> Regards,
>
> Brad
>
------------------------------
Date: Mon, 08 Mar 2004 12:35:33 -0600
From: Bill Ding <carpenter@construction.net>
Subject: Re: CPAN shell complains about MD5
Message-Id: <nkep40hl8i7grvk7p4vevad04p3icit1ud@4ax.com>
Ben Morrow <usenet@morrow.me.uk> (not long ago, on Mon, 8 Mar 2004
17:21:06 +0000 (UTC)) cracked his knuckles, flexed his fingers, and
proceeded to cut, paste, and type:
>
>Quoth Uranus Corporation:
>> Ben Morrow <usenet@morrow.me.uk> typed:
>>
>> >> Bill:
>> >> ...fact, everything I tried complained about MD5, specifically:
>> >>
>> >> 'Can't locate object method "new" via package MD5
>> >> (perhaps you forgot to load "MD5"?) at
>> >> /usr/lib/local/perl5/5.6.1/CPAN.pm line 4212'
>> >>
>> >> except install MD5, which proclaimed "MD5 is up to date."
>> >>
>> >> Hmmmm... it's up to date, but it's not there. What gives, and how to
>> >> fix it?
>>
>> > Ben:
>> >Do you have and MD5.pm installed?
>>
>> Do I have =what= and MD5.pm installed?
>
>Sorry: 'an MD5.pm'. My meaning was: is there actually an MD5.pm on your system,
>or is CPAN.pm being stupid.
>
Ah. Well, I think the answer was "yes".
>> I tried (see above) 'install
>> MD5' and the result was that it's "up to date". But then it's "not
>> found".
>>
>> > Ben:
>> >Where? Is it in your @INC? Is its .so in a
>> >suitable place?
>>
>> As to MD5.pm's location, it's in that directory along with the CPAN.pm
>> that's being complained about. If it weren't somewhere at least partly
>> suitable, I wouldn't have thought install would be able to find it and
>> declare it "up to date", but apparently it's not =completely=
>> suitable. What's the name of its .so?
>
>MD5.so :)
>
>> I do find an MD5.so, but it's in
>> a 5.6.0 directory, and moving it to a directory in the @INC path
>> didn't seem to make any difference.
>
>Nononono, moving .sos around is a bad idea...
Oh, I agree 100%... However, it was straw-grasping time, as in "hell's
fahr, bubba, it already ain't werkin', so 'zackly how much worse yew
reckon it kin git?"
>I think the best solution is just to delete that MD5.pm. Then CPAN won't
>find it, and you can install Digest::MD5... where it came from I don't
>know: the only one I've got is in a site_perl directory.
I'll give that a shot - thanks.
>> Since MD5 is not explicitly
>> required or used in that CPAN.pm, is it looking for a .al instead?
>
>No. It is required at runtime: in my version lines 3893-8:
>
>if ($CPAN::META->has_inst("Digest::MD5")) {
> $self->debug("Digest::MD5 is installed, verifying");
> $self->verifyMD5;
>} else {
> $self->debug("Digest::MD5 is NOT installed");
>}
>
>.
>
>> But it also didn't generate a new error, so I assume that means that
>> perl DID find its MD5 module, and the message actually means that the
>> MD5 authentication is not running. This is a RH7.2 system; I looked in
>> the system configuration options, and MD5 doesn't appear in the list
>> of available services, although it was (and is) checked in the
>> kickstart.
>
>I'm not sure what you mean by this: MD5 isn't a 'service', it's just an
>algorithm, a way of taking one number and producing another which is
>almost but not entirely unlike the first. Whatever you found in
>'kickstart' has nothing to do with Perl's MD5.pm.
Again, straw-grasping... it ocurred to me that perhaps authentication
included some kernel code that wasn't being run, so I was looking
around for something external to perl.
Thanks for the ideas!
------------------------------
Date: 8 Mar 2004 18:03:20 -0800
From: zhao_wu@pmc-sierra.com (Zhao Wu)
Subject: function override
Message-Id: <8ec9eeab.0403081803.48e8f713@posting.google.com>
How do I override a member function temporarily?
For example, redirect_ok() is a function defined in LWP::UserAgent.
I can override it with:
sub LWP::UserAgent::redirect_ok { .... }
However, what if I want to revert the override? Or how do I make it
only effective in one subroutine?
Another related question is I always get a warning from this.
How do I supress the warning message (I still want warnings but just
not on this one)?
thanks,
-- Zhao
------------------------------
Date: Mon, 08 Mar 2004 22:40:27 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Is it possible to impose a timeout on <>?
Message-Id: <pkent77tea-66CC65.22401908032004@pth-usenet-01.plus.net>
In article <e8f67309.0403080314.348f25e2@posting.google.com>,
megapode@hotmail.com (Bob Dubery) wrote:
> pkent <pkent77tea@yahoo.com.tea> wrote in message
> news:<pkent77tea-0167A5.11584706032004@pth-usenet-02.plus.net>...
...
> > alarm($alarmtime);
> On UNIX that is. It runs without warning (even with strict and -w) on
> Windows, but it never times out :-(
Aaah, I do remember that alarm() wasn't implemented on Activestate Perl
in the past... but looking at the docs on my PC (perl 5.8.0 build 805)
it only says "not implemented (Win32)" yet a simple script containing a
call to alarm() says...
Terminating on signal SIGALRM(14)
Which seems to be exactly the right thing to do. Odd. Maybe the alarm
doesn't work with the blocking reads like it does on unix? Maybe your
best bet is to use select, sysread, or something to do nonblocking
reads... see examples at http://modperl.com:9000/perl_networking/
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Mon, 08 Mar 2004 20:56:31 GMT
From: anonymous@coolgroups.com
Subject: Re: MS SQL 2000
Message-Id: <00bead094eba17f3cfcd0e6a54b9e1d5@news.scbiz.com>
So, should this code work on a Unix system:
my $dbhandle = DBI->connect(
"DBI:ADO:DRIVER={SQL
Server};SERVER=$servername;DATABASE=$dbname",
$uid, $pwd,{ RaiseError => [1],
PrintError => [1],
AutoCommit => [1])
) || die "Db connection not made: $DBI::errstr";
anonymous@coolgroups.com wrote:
> Does anyone know how to connect to an MS SQL 2000 db from
> Perl?
>
> thanks.
>
------------------------------
Date: Mon, 08 Mar 2004 20:59:21 GMT
From: anonymous@coolgroups.com
Subject: Re: MS SQL 2000
Message-Id: <d8690251e4edb78f514e78531eb33537@news.scbiz.com>
How exactly do I create a DSN? I don't see any Data Sources
option in my windows control panel.
------------------------------
Date: Mon, 8 Mar 2004 21:41:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: MS SQL 2000
Message-Id: <c2ipat$ib0$1@wisteria.csv.warwick.ac.uk>
[quoting fixed. don't top-post]
Quoth anonymous@coolgroups.com:
> anonymous@coolgroups.com wrote:
> >
> > Does anyone know how to connect to an MS SQL 2000 db from
> > Perl?
> >
> > thanks.
>
> So, should this code work on a Unix system:
>
> my $dbhandle = DBI->connect(
> "DBI:ADO:DRIVER={SQL
> Server};SERVER=$servername;DATABASE=$dbname",
> $uid, $pwd,{ RaiseError => [1],
> PrintError => [1],
> AutoCommit => [1])
> ) || die "Db connection not made: $DBI::errstr";
I doubt it, as I thing DBD::ADO needs Win32 to run. Try using DBD::Sybase.
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: Mon, 08 Mar 2004 19:06:54 -0500
From: L D Jones <734562323@yahoo.de>
Subject: Re: MS SQL 2000
Message-Id: <404D0A9E.DF91FEFD@yahoo.de>
anonymous@coolgroups.com wrote:
>
> How exactly do I create a DSN? I don't see any Data Sources
> option in my windows control panel.
one place the answer can found is on google
------------------------------
Date: Mon, 08 Mar 2004 19:15:19 GMT
From: whoknows <whoknows@NoSpamPLZ.net>
Subject: Re: Need help with Undeliverable Emails
Message-Id: <bD33c.23111$q4.132889@weber.videotron.net>
On Mon, 8 Mar 2004 17:36:46 +0000 (UTC), Ben Morrow wrote:
>
> Quoth whoknows@NoSpamPLZ.net:
>
> Yes there is. Use Net::SMTP, but connect to localhost. Mail will be
> queued by your local MTA as usual. If it fails then your invocation of
> sendmail would have failed as well.
>
That implies running a mail daemon on every host. Too much overhead -
managing/patching/etc. The best way is to (safely) use sendmail binary
and have a cronjob entry with 'sendmail -q' to flush the queue.
--
.signature: No such file or directory
------------------------------
Date: 08 Mar 2004 11:44:37 -0800
From: Vilmos Soti <vilmos@vilmos.org>
Subject: Re: open (FAILEHANDLER, ">>$filename") what is the rong with that
Message-Id: <87n06r6s4a.fsf@localhost.localdomain>
samehabdelatef@yahoo.com (Sameh Abdelatef) writes:
> Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message news:<um5b2c.116.ln@goaway.wombat.san-francisco.ca.us>...
> > -----BEGIN xxx SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > [comp.lang.perl is dead, baby]
> >
> > On 2004-03-06, Sameh Abdelatef <samehabdelatef@yahoo.com> wrote:
> > >
> > > I used to use[ open (FAILEHANDLER, ">>$filename");] to open and add
> > > new lines to $filename, but it didn't work any more.
Just a quick note. Are you sure it is "FAILE" and not "FILE"?
Maybe just a typo?
Vilmos
------------------------------
Date: Mon, 8 Mar 2004 12:46:39 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: open (FAILEHANDLER, ">>$filename") what is the rong with that
Message-Id: <f3mi2c.csj.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-03-08, Sameh Abdelatef <samehabdelatef@yahoo.com> wrote:
> Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message news:<um5b2c.116.ln@goaway.wombat.san-francisco.ca.us>...
>>
>> On 2004-03-06, Sameh Abdelatef <samehabdelatef@yahoo.com> wrote:
>> >
>> > I used to use[ open (FAILEHANDLER, ">>$filename");] to open and add
>> > new lines to $filename, but it didn't work any more.
>>
>> Define ''didn't work''--post a short script that duplicates the problem,
>> and what happens when you run the script.
>
> When the script run it did not write any thing to the file as
> expected, also return empty page with out completing the rest of
> script. There is no error occurs at the error log file.
> I'm so sorry if I describe the problem in brief
You're still too brief--can you post code, as I asked previously?
(Though Anno's diagnosis that the filesystem is full is worth
investigating.)
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFATNuuhVcNCxZ5ID8RAssKAKCKEe//x+fa8FYMS6OEqD1ZnNMQPACeMyvV
PoijsjLH926oqxNA8yM9HXI=
=To2T
-----END PGP SIGNATURE-----
------------------------------
Date: 8 Mar 2004 17:22:34 -0800
From: ohmy9od@yahoo.com (Oeln)
Subject: Ordering large files (in perl?)
Message-Id: <ffde43bc.0403081722.6fdc2988@posting.google.com>
I've got a large file in which there is one word on each line. I've
got to output each word it includes to a new file, in order. I've
currently got the following:
@order = <INFILE>;
@ordered = sort(@order);
foreach $o (@ordered) {
print OUTFILE "$o";
}
In general this is working fine; but if I've got to open a larger file
(over 1gb, for example, or even 10 gb..whatever) it fails.
I've found this issue being gone over to an extent; but the
information is not clear to me. I've got a few ideas on how to get
this to work (for instance, if I could get one word out of the infile
at a time and insert it to the outfile, in order in the first place;
but I'd imagine this would be incredibly inefficient).
One idea I came upon implied that exec(sort) would be a good option.
I'd imagine like exec(sort INFILE -o OUTFILE); but I'm not certain, or
clear on the other options it offers. Is that good enough by itself
for large files? I get the impression there is a way to output to a
group of temp files, and then 'integrate' them into one file, etc.
etc.
I guess what I'm looking for is either guidance to further info on
this, or example code. I'd like to 'get' what's going on tho either
way, though. I'm interested in the learning experience, too - not only
in getting it to work.
I'm on fedora linux/perl 5.8.3 installed. I've only got 128mb on here,
which I imagine is on of my issues..
Thank you for any input on this.
------------------------------
Date: 9 Mar 2004 01:37:02 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Ordering large files (in perl?)
Message-Id: <c2j73u$16$1@canopus.cc.umanitoba.ca>
In article <ffde43bc.0403081722.6fdc2988@posting.google.com>,
Oeln <ohmy9od@yahoo.com> wrote:
:I've got a large file in which there is one word on each line. I've
:got to output each word it includes to a new file, in order. I've
:currently got the following:
: @order = <INFILE>;
: @ordered = sort(@order);
:In general this is working fine; but if I've got to open a larger file
:(over 1gb, for example, or even 10 gb..whatever) it fails.
:I'm on fedora linux/perl 5.8.3 installed. I've only got 128mb on here,
:which I imagine is on of my issues..
At 1 Gb for the input file, you are probably exceeding your address
space limitations (32 bit address space often implies a limit of 2 Gb
total process size, as 1 bit of the address space is often reserved by
the system.)
I suggest you research mergesort .
--
History is a pile of debris -- Laurie Anderson
------------------------------
Date: Tue, 9 Mar 2004 09:44:12 +0800
From: "Koms Bomb" <komsbomb@hotmail.com>
Subject: Re: Ordering large files (in perl?)
Message-Id: <c2j7ft$1tdf37$1@ID-165313.news.uni-berlin.de>
"Oeln" <ohmy9od@yahoo.com> wrote in message
news:ffde43bc.0403081722.6fdc2988@posting.google.com...
> I've got a large file in which there is one word on each line. I've
> got to output each word it includes to a new file, in order. I've
> currently got the following:
>
> @order = <INFILE>;
> @ordered = sort(@order);
>
> foreach $o (@ordered) {
> print OUTFILE "$o";
> }
If you're on 32bit machine, I don't think it's manipulable or possible to
sort more
than 1G data in memory.
Try to choose a good algorithm that sort data on the disk rather than using
Perl's internal 'sort'.
--
Koms Bomb
*****Pardon my poor English*****
---------------------
My TASM homepage, resource for assembly. Tools, articles, links.
http://komsbomb.ols-lab.com
------------------------------
Date: Mon, 08 Mar 2004 20:17:52 GMT
From: support@wildapache.net (WA Support)
Subject: pack/unpack question
Message-Id: <404ccfdf.1647909839@news.wildapache.net>
Hello,
I am trying to read a file of binary records using the unpack function.
The files records have a layout like so:
Detailed layout on x86: offset(length)
0(1) char op;
1(3) char padding[3]
4(4) int swap_file_number;
8(4) time_t timestamp;
12(4) time_t lastref;
16(4) time_t expires;
20(4) time_t lastmod;
24(4) size_t swap_file_sz;
28(2) u_short refcount;
30(2) u_short flags;
32(16) unsigned char key[MD5_DIGEST_CHARS];
I create a binary layout land get the record length like so:
$binary_layout = "A1 x3 i l l l l l s s A16";
$recordlen = length pack $binary_layout, "";
and read the records in:
open SWAP_STATE, "<$swap_state";
until ( eof(SWAP_STATE) ) {
if ( ! read SWAP_STATE, $record, $recordlen ) {
print "Failed to read initial record in $swap_state\n";
die;
}
($op, $filenum, $timestamp, $lastref, $expires,$lastmod, $filesz, $refcount, $flags, $key) =
unpack $binary_layout, $record;
<snip>
The problem is, I can't seem to get at the $op value. $op should be either 0 or 1, but when I print it, I get ^A.
I have tried to unpack into ($op,$pad,$filenum,...) but that shifted all my other variables 4 bytes.
Does any one know how I can get the proper value out of $op here?
Thanks,
Murrah Boswell
------------------------------
Date: 8 Mar 2004 21:37:50 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: pack/unpack question
Message-Id: <c2ip3e$et0$1@nets3.rz.RWTH-Aachen.DE>
Also sprach WA Support:
> I am trying to read a file of binary records using the unpack function.
>
> The files records have a layout like so:
>
> Detailed layout on x86: offset(length)
>
> 0(1) char op;
> 1(3) char padding[3]
> 4(4) int swap_file_number;
> 8(4) time_t timestamp;
> 12(4) time_t lastref;
> 16(4) time_t expires;
> 20(4) time_t lastmod;
> 24(4) size_t swap_file_sz;
> 28(2) u_short refcount;
> 30(2) u_short flags;
> 32(16) unsigned char key[MD5_DIGEST_CHARS];
>
> I create a binary layout land get the record length like so:
>
> $binary_layout = "A1 x3 i l l l l l s s A16";
> $recordlen = length pack $binary_layout, "";
>
> and read the records in:
>
> open SWAP_STATE, "<$swap_state";
>
> until ( eof(SWAP_STATE) ) {
>
> if ( ! read SWAP_STATE, $record, $recordlen ) {
> print "Failed to read initial record in $swap_state\n";
> die;
> }
>
> ($op, $filenum, $timestamp, $lastref, $expires,$lastmod, $filesz, $refcount, $flags, $key) =
> unpack $binary_layout, $record;
>
><snip>
>
> The problem is, I can't seem to get at the $op value. $op should be
> either 0 or 1, but when I print it, I get ^A.
Which is the natural thing to happen. Watch:
print ord "\cA";
__END__
1
That means 'op' holds the numerical value 1. It does not contain the
character '1' which would have the numerical value 49 in ASCII.
Having said that, you can change your template to
c1 x3 i l l l l l s s A16
and then you will get a 'real' 1 into the $op, that is: $op will hold an
integer instead of a string with the first byte set to 1.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 8 Mar 2004 21:30:14 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: pack/unpack question
Message-Id: <c2ioj1$tsf$1@news.simnet.is>
"WA Support" <support@wildapache.net> wrote in message
news:404ccfdf.1647909839@news.wildapache.net...
[snip unpack]
> The problem is, I can't seem to get at the $op value. $op should be
either 0 or 1, but when I print it, I get ^A.
^A is chr(1)
you obviously are getting the chars \000 and \001
if you want the chars '0' and '1' , you could simply add ord('0') to their
ordinal values
$op=chr(ord($op)+ord('0'));
or
$op=chr(ord($op)+48);
or simply
$op|='0';
alternately, you might want to us C1 instead of A1 on the unpack
gnari
------------------------------
Date: 8 Mar 2004 15:47:37 -0800
From: 6tc1@qlink.queensu.ca (Novice)
Subject: parsing smime files using Perl
Message-Id: <b80e4a77.0403081547.f9d3550@posting.google.com>
Hi all, I've recently returned to using Perl after over 5 years off
and am thus going through all the tutorials and have decided to do a
small project of parsing the smime file that is created on my mail
server.
Everything is pretty straightforward except determining the end of the
text message that is in the e-mail.
At the start of every message is the field:
<newline>
From <email address> <date>
However, it is concieveable that that same text (in that format) will
be found within the text of the email message. Is there a standard
way of determining when I have reached a new message or when I may
have simply encountered some text (in the content of an e-mail) that
is identical to the header of an e-mail?
Right now I just have the Perl program grabbing each of the standard
fields (To, From, Subject, Cc, etc), rearrange them according the
order that I want to appear, and then assume the text of the e-mail is
all of the text until it encounters:
<newline>
From <email address> <date>
which can easily be made to fail, since I can put the above text into
the text of one of my e-mails.
Thanks,
Novice
------------------------------
Date: Tue, 09 Mar 2004 01:01:32 +0100
From: Amir Kadic <zoooz@gmx.de>
Subject: Re: parsing smime files using Perl
Message-Id: <c2j1lo$1u88el$1@ID-142982.news.uni-berlin.de>
Novice wrote:
> Everything is pretty straightforward except determining the end of the
> text message that is in the e-mail.
I just sent a message to myself (locally) containing a
From ...
line in the body and exim transformed it into
>From ...
Guess you have to find out how your server handles this.
HTH
------------------------------
Date: Mon, 08 Mar 2004 12:30:11 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: scheduling a perl script
Message-Id: <080320041230113771%jgibson@mail.arc.nasa.gov>
In article <dfd17ef4.0403052053.632e2e8e@posting.google.com>, mike
<s99999999s2003@yahoo.com> wrote:
> hi
>
> i wrote a script that is supposed to check a directory and see if
> there is a file named "test.txt" there and if there is , use ftp to
> transfer the file to another server and then remove the file from the
> directory.
> I had scheduled a job in windows to poll for this directory looking
> for "test.txt" every month on day 8, 9 and 10 and 11, because test.txt
> will arrive anytime during 8,9 and 10. On the 11th, my script will
> poll the directory and if there is still no test.txt, will alert the
> administrator.
>
> How can i implement in perl such that on the 11th, my script will not
> mistake that test.txt is not there while in fact, it has already been
> transfered to another server and removed after transfered?
> I thought of not removing test.txt after transfered but if the file
> arrived on the 8th, then on the 9th i would do another identical
> transfer.
Before you do anything, check the destination server. If the file is
already there (with the proper modification date), do nothing.
[ status file method snipped ]
------------------------------
Date: 8 Mar 2004 22:07:02 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrnc4prk6.3oc.sholden@flexal.cs.usyd.edu.au>
On Mon, 8 Mar 2004 18:46:13 +0000,
James Taylor <spam-block-@-SEE-MY-SIG.com> wrote:
> In article <104p97478jcdq2b@corp.supernews.com>,
> Greg Bacon <gbacon@hiwaay.net> wrote:
>>
>> Bottom 11 Posters by OCR (minimum of ten posts)
>> ===============================================
>>
>> (kb) (kb)
>> OCR orig / body Posts Address
>> ----- -------------- ----- -------
>>
>> 0.895 ( 39.5 / 44.2) 18 tadmc@augustmail.com
>> 0.588 ( 20.2 / 34.3) 45 "gnari" <gnari@simnet.is>
>
> Eh? That can't be right.
Why can't that be right? Please note the minimum post
requirement and the fact that there were only 11 posters who met it.
>> Bottom 12 Threads by OCR (minimum of ten posts)
>> ===============================================
>>
>> (kb) (kb)
>> OCR orig / body Posts Subject
>> ----- -------------- ----- -------
>>
>> 0.711 ( 8.8 / 12.4) 17 webservices
>> 0.595 ( 9.2 / 15.4) 12 Regex comparison
>
> Nor can that. What's up Greg?
Same here.
--
Sam Holden
------------------------------
Date: Tue, 9 Mar 2004 01:06:23 +0100
From: hexelbox@gmx.de (Juergen Kuehne)
Subject: Re: Unwanted newline or eol between fields
Message-Id: <1gacuyl.1urype015p73uN@pd9512443.dip.t-dialin.net>
David Efflandt <efflandt@xnet.com> wrote:
> On 5 Mar 2004 13:37:55 -0800, Suzie Wilks <wazopst@yahoo.com> wrote:
> > I have a file that looks a bit like this:
> > [...]
> > 0.002
> > 0.007
> > 0.038
> >
> Newlines vary with the OS (or data source). So perhaps you are stripping
> linefeeds and forgetting about hidden carriage returns or vice versa.
>
> "\n" eq "\015\012" in DOS/Win (or web form textarea), "\012" in Unix,
> "\015" in Mac (but not sure about OSX which is Unix like).
A simple hint, though nothing do do with regex:
I have mentioned results like above, when doing copy/paste (while
visiting websites) from old Netscape version (Mac) to text-editor:
Netscape is not able to handle table contents correctly. When having
troubles with table-contents while copying I quickly change to Internet
Explorer which is able to handle table contents ;-)
regards
Juergen
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6235
***************************************