[17941] in Perl-Users-Digest
Perl-Users Digest, Issue: 101 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 19 18:05:46 2001
Date: Fri, 19 Jan 2001 15:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979945512-v10-i101@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 Jan 2001 Volume: 10 Number: 101
Today's topics:
Re: Another newbie <ansel@babylon.dyndns.org>
Re: Another newbie <ansel@babylon.dyndns.org>
Re: Call C function in XS from C function in the same X <time4tea@monmouth.com>
Re: Child processes don't clean up (defunct processes l <mischief@velma.motion.net>
Re: email reply neurofase@my-deja.com
file size discrepancies between unix and windows moeg@my-deja.com
Re: file size discrepancies between unix and windows <jamie.oshaughnessy@ntlworld.com>
Re: file size discrepancies between unix and windows grommel@my-deja.com
Re: file size discrepancies between unix and windows (Tad McClellan)
Re: flock <elijah@workspot.net>
Re: How much time does a subroutine call take? (Chris Fedde)
how to send a big file pipeing to sendmail metamp@my-deja.com
Re: MIME Lite Problem (Rand Simberg)
Re: MIME Lite Problem (Chris Fedde)
Re: MIME Lite Problem (Rand Simberg)
Re: MIME::Parser Finding decoded files <elijah@workspot.net>
Re: My hash slice is yielding a syntax error.. please h <comdog@panix.com>
Re: My hash slice is yielding a syntax error.. please h <ren.maddox@tivoli.com>
Re: My hash slice is yielding a syntax error.. please h <uri@sysarch.com>
Path env setting on Win32 <data_64@my-deja.com>
Re: Path env setting on Win32 <djberg96@my-deja.com>
Re: Perl OOP questions <uri@sysarch.com>
Re: Perl OOP questions <jhiver@cisedi.com>
Re: Perl script problem <ian@ianwaters.com>
Re: Perl script problem jdf@pobox.com
Re: Perl Style Guide - uncuddled elses <prlawrence@lehigh.edu>
Re: Perl Style Guide - uncuddled elses (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jan 2001 11:45:10 -0800
From: Ansel Sermersheim <ansel@babylon.dyndns.org>
Subject: Re: Another newbie
Message-Id: <8766jbpbqx.fsf@redhawk.babylon.dyndns.org>
>bernard.el-hagin@lido-tech.net (Bernard El-Hagin) writes:
>> On Fri, 19 Jan 2001 15:08:23 GMT, mattfenn@my-deja.com
>> <mattfenn@my-deja.com> wrote:
>>
>> >I'm having trouble matching each word for only one vowel. Any
>> >ideas?
>>
>> A rather simple, but ugly way of counting the number of vowels:
>Here's a simple, less ugly way:
>$_ = "abba";
>my $vowels = tr/aeiou//; # I excluded "y" as the OP didn't mention it
>print "Too many vowels in $_\n" if $vowels > 1;
Playing around with more regexish ways of doing it, I found this
rather odd answer for the poster's problem:
undef $/;
@words{split /\W+/, <> }=();
@validwords = grep {/^(..)+$/==tr/aeiou//} keys %words);
Wierd idiom, but I kinda like it.
-Ansel
--
$_{\$,}=[];@,=(%_,\%_,\*_,sub{},'JaPH'x2);y/0-9a-y//d,for(@,);map{$_ x=3}@,;$q=
join'',sort'$y=shift@,; $y^= int(eval$q) $q=q-my eval${q}if@,;$y-;pr'=~/\S*/g;$
_=q]"^vp|\@Zi0e|12O7340CP567M[,"];s@\d@\$][$&]@g;@]=(split'',unpack qq^$&q^^q^,
^^q,nQ,,q^)%1T&'`P%"SD`^);push@,,eval;eval(('JXKCC'^q^/.*/g^).$q=~/(.{6}).$/g);
------------------------------
Date: 19 Jan 2001 12:00:05 -0800
From: Ansel Sermersheim <ansel@babylon.dyndns.org>
Subject: Re: Another newbie
Message-Id: <871ytzpb22.fsf@redhawk.babylon.dyndns.org>
I wrote:
>Playing around with more regexish ways of doing it, I found this
>rather odd answer for the poster's problem:
>undef $/;
>@words{split /\W+/, <> }=();
>@validwords = grep {/^(..)+$/==tr/aeiou//} keys %words);
Ack! pilot error. Cut-n-pasted from the wrong xterm. This doesn't
even compile.
Correct, tested code:
undef $/;
@words{split /\W+/, <>}=();
@validwords = grep {/^(..)+$/ && tr/aeiouAEIOU//==1} keys %words;
-Ansel
--
$_{\$,}=[];@,=(%_,\%_,\*_,sub{},'JaPH'x2);y/0-9a-y//d,for(@,);map{$_ x=3}@,;$q=
join'',sort'$y=shift@,; $y^= int(eval$q) $q=q-my eval${q}if@,;$y-;pr'=~/\S*/g;$
_=q]"^vp|\@Zi0e|12O7340CP567M[,"];s@\d@\$][$&]@g;@]=(split'',unpack qq^$&q^^q^,
^^q,nQ,,q^)%1T&'`P%"SD`^);push@,,eval;eval(('JXKCC'^q^/.*/g^).$q=~/(.{6}).$/g);
------------------------------
Date: Fri, 19 Jan 2001 17:21:17 -0500
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: Call C function in XS from C function in the same XS file
Message-Id: <94aeoc$u0u$1@nntp9.atl.mindspring.net>
"Ilya Zakharevich" <ilya@math.ohio-state.edu> wrote in message
news:949pv5$5p7$1@charm.magnus.acs.ohio-state.edu...
> No need for all these complications. After you defined your C
> function void plusone( int i, int times ), just ask XS to make the
> Perl entry point for it:
>
> MODULE = Rubbish PACKAGE = Rubbish
>
> void plusone( int i, int times );
>
Yes, you are of course right... although I'm never very good at leaving the
xs processor to do this kind of work, in this case it
was intentional. I was trying to show that although the xs function _looks_
like it might be called PlusOne, it actually isn't,
and that if you wanted to call the function recursively,or from another xs
function, you can't (at least not in a simplistic way)
so
MODULE = [.....]
void PlusOne( int i, int times ) {
[...]
PlusOne(i++, times--)
}
/*or*/
void PlusOneAgain ( int i, int times ) {
[...]
PlusOne ( i,times);
}
isn't going to work..(well, AFAIK) ....(I think that was what the original
poster was trying to do (?) )
Cheers!
James
------------------------------
Date: Fri, 19 Jan 2001 22:07:26 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Child processes don't clean up (defunct processes left) even though SIGCHLD does wait()
Message-Id: <t6heku26f8cp5e@corp.supernews.com>
Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> wrote:
> On Fri, 19 Jan 2001 03:37:27 -0000,
> Chris Stith <mischief@velma.motion.net> wrote:
>>
>>There are ways to reap using Perl waitpid() without waitpid() being
>>implemented on the system, such as keeping around an array of your child
>>pids and looping through it with a blocking waitpid() for each child pid.
> Once you run out of children to wait for the wait won't block anymore.
> If a child is still running the wait will block until one of them
> terminates. and if the main process has important thing to do then it
> won't be able to.
In the example shown, the parent makes sure there are a certain number
of children until the parent is asked to terminate. A waitpid on a
particular pid will block until that pid exits. In a loop as shown in
the example to which the above quoted text was referring, the waitpid()
may wait out of order, so it will block much of the time. I did give the
caveat about the parent process in this scenario not being very useful
except to manage the children.
> A technique sometimes used is to double fork, that is fork a child and
> let this child fork a grand child and immidiatly terminate. The
> original process can then wait for the child without risk of the wait
> blocking. The grandchild will now be orphaned, and won't therefore
> become a zombie when it terminates. The init process will see to it
> that this doesn't happen.
If you don't want to wait on your children, the very easy way to
do so in Perl is to set $SIG{CHLD} = 'IGNORE';
Double-forking is good for getting a demon process started, though.
[snip Villy's example]
Chris
--
Christopher E. Stith
For the pleasure of others, please adhere to the following
rules when visiting your park:
No swimming. No fishing. No flying kites. No frisbees.
No audio equipment. Stay off grass. No pets. No running.
------------------------------
Date: Fri, 19 Jan 2001 19:52:46 GMT
From: neurofase@my-deja.com
Subject: Re: email reply
Message-Id: <94a5ua$nj$1@nnrp1.deja.com>
I tried that but it does not seem to work, is there anyother way???/?
In article <slrn96fm52.1q4.efflandt@efflandt.xnet.com>,
efflandt@xnet.com wrote:
> On Thu, 18 Jan 2001, neurofase@my-deja.com <neurofase@my-deja.com>
wrote:
> >I am using perl to convert a form on the internet into an email but
i was
> >looking to make it that the email came from the email addy that was
> >entered by the user so it was easier to reply. The bit that is
getting
> >me is i have to use the \ in the email. Can anyone help?
>
> You don't need the \ in an e-mail address you get from a web form.
>
> You may also want to include a Reply-To: header just in case your mail
> server sets the From: header to who it thinks it really is from (you
or
> the webserver).
>
> Assuming you are using CGI.pm function mode and the field is called
> 'email' you would simply:
>
> $smtp->datasend("From: " . param('email') . "\n");
> $smtp->datasend("Reply-To: " . param('email') . "\n");
>
use Net::SMTP;
$smtp = Net::SMTP->new('EXCHANGE'); # connect to an SMTP server
$smtp->mail( 'website@ozarks.edu' ); # use the sender's address here
$smtp->to('lgarriso@email.com', 'webmaster@email.com'); # recipient's
address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: lgarriso\@email.com, webmaster\@ozarks.edu\n");
$smtp->datasend("From: website\@email.com\n");
$smtp->datasend("Subject: Satisfaction Survey of Maintance Request
(from Web Site)\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Time Sent(Local) $now\n");
$smtp->datasend("\n");
$smtp->datasend("Survey on Work Requested\n");
$smtp->datasend("E-mail: $input{'email'}\n");
Sent via Deja.com
http://www.deja.com/
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:17:36 GMT
From: moeg@my-deja.com
Subject: file size discrepancies between unix and windows
Message-Id: <94a7cm$20i$1@nnrp1.deja.com>
Hello all,
I'm really stuck and I'm looking for suggestions. I'm moving files via
ftp from a windows 98 machine to a linux box using active state perl.
It's necessary to do a file size check before I can unlink the source
to be certain the file transfere was ok. Problem is, there's a file
size difference bettween the two. Yet if I move it back to the win
machine to a different directory the file size is the same. Is this an
os filesystem issue? I'm hoping someone somewhere can help me out. Is
there a way to calculate the differnce reliably? Help! I've included a
snippet of my code below. Thanks a bunch.
if($_ =~ /\.wav$/)
{
if (-M $configuration{WIN_LOCAL_WAV_FILE_DIRECTORY} . $_ >.0078125)
#this is 11.75 mins
{
$size = -s $configuration{WIN_LOCAL_WAV_FILE_DIRECTORY} . $_;
$waves_and_sizes{$_} = $size;
}
}
$ftp = Net::FTP->new($configuration{COMPRESSOR_URL},Timeout=>20);
$ftp->login($configuration{FTP_USERNAME},
$configuration{FTP_PASSWORD}) or die "login failed";
foreach $key (keys (%waves_and_sizes))
{
$ftp->put($configuration{WIN_LOCAL_WAV_FILE_DIRECTORY} . $key,
$configuration{FTP_WORKING_DIRECTORY}."/".$key) or die "cannot move
file ". $configuration{WIN_LOCAL_WAV_FILE_DIRECTORY}.$key."\n Sys
error =". $! ."\n" ;
print"new file size = $waves_and_sizes{$key}\n";
$test_size = -s $configuration{COMPRESSOR_DIRECTORY_FOR_NEW_WAVES}
. $key;
print"size = $test_size\n";
if( -s $configuration{COMPRESSOR_DIRECTORY_FOR_NEW_WAVES} . $key ==
$waves_and_sizes{$key})
{
print"unlinking source\n";
unlink ($configuration{WIN_LOCAL_WAV_FILE_DIRECTORY}.$key) or
warn "cannot unlink". $waves_and_sizes{$key}."\n";
}
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:50:25 +0000
From: Jamie O'Shaughnessy <jamie.oshaughnessy@ntlworld.com>
Subject: Re: file size discrepancies between unix and windows
Message-Id: <r2ah6t0kgneojfj86dv4pgopj4pidfupna@4ax.com>
On Fri, 19 Jan 2001 20:17:36 GMT, moeg@my-deja.com wrote:
>Hello all,
>
>I'm really stuck and I'm looking for suggestions. I'm moving files via
>ftp from a windows 98 machine to a linux box using active state perl.
>It's necessary to do a file size check before I can unlink the source
>to be certain the file transfere was ok. Problem is, there's a file
>size difference bettween the two. Yet if I move it back to the win
>machine to a different directory the file size is the same. Is this an
>os filesystem issue? I'm hoping someone somewhere can help me out. Is
>there a way to calculate the differnce reliably? Help! I've included a
>snippet of my code below. Thanks a bunch.
Not looked at your code as it was a bit garbled, but remember, line
endings on UNIX and DOS are different and so that will account for an
extra character per line, hence different file sizes.
Jamie
------------------------------
Date: Fri, 19 Jan 2001 20:40:08 GMT
From: grommel@my-deja.com
Subject: Re: file size discrepancies between unix and windows
Message-Id: <94a8n6$39u$1@nnrp1.deja.com>
In article <94a7cm$20i$1@nnrp1.deja.com>,
moeg@my-deja.com wrote:
> Hello all,
>
> I'm really stuck and I'm looking for suggestions. I'm moving files
via
> ftp from a windows 98 machine to a linux box using active state perl.
> It's necessary to do a file size check before I can unlink the source
> to be certain the file transfer was ok. Problem is, there's a file
> size difference between the two. Yet if I move it back to the win
> machine to a different directory the file size is the same....
I haven't looked at your code in detail, but as you guessed, the
problem is that Linux and Windows handle files differently. By default,
FTP transfers files in ASCII text mode, which means it expects a text
file with each line ended by an end-of-line terminator. The Unices,
including Linux, use a terminator of LineFeed (a.k.a. ctrl-J or x'0A'),
but DOS and Windows use two characters, CarriageReturn + LineFeed
(a.k.a. ctrl-M ctrl-J or x'0D0A'). Thus, when transferring files from
Windows to Linux, all occurrences of x'0D0A' get changed to x'0A', so
the filesize is different; but when you transfer it back, the x'0A's
get changed to x'0D0A', and it's the same again!
Anyhow, the fix is easy. Just tell FTP that you want to transfer the
file in BINARY mode rather than ASCII. This will cause the file to be
treated as a plain old stream of bytes with no translation. I don't
know how the FTP module does this, but it should be easy to find in the
POD.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:50:31 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: file size discrepancies between unix and windows
Message-Id: <slrn96h3d3.881.tadmc@tadmc26.august.net>
moeg@my-deja.com <moeg@my-deja.com> wrote:
>
>I'm really stuck and I'm looking for suggestions. I'm moving files via
>ftp from a windows 98 machine to a linux box using active state perl.
You should always use "ASCII" or "text" mode (not "binary")
FTP mode then so that it will convert the line ending sequences
for you.
>It's necessary to do a file size check before I can unlink the source
>to be certain the file transfere was ok. Problem is, there's a file
>size difference bettween the two.
If they are text files, then there is _supposed_ to be a file
size difference.
Unix uses 1 char to mark line endings. Windoze uses 2 chars.
The difference in filesize should be the same number of bytes
as there are lines in the text file.
>Yet if I move it back to the win
>machine to a different directory the file size is the same.
Sounds like your FTP program is working just as it should.
>Is this an
>os filesystem issue?
No.
>I'm hoping someone somewhere can help me out.
I'm hoping I did that.
>Is
>there a way to calculate the differnce reliably?
See above. (or, transfer in "binary" mode, check sizes, then adjust
line endings yourself).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 2001 20:57:25 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: flock
Message-Id: <eli$0101191548@qz.little-neck.ny.us>
In comp.lang.perl.misc, Brian Pontz <pontz@NO_SPAM.channel1.com> wrote:
> I came across the below code on the web. My question is
It is in the current perl documentation for flock().
> why do you need the seek(MBOX, 0, 2) ? It's my understanding that (on
> unix ) when you open a file for appending, you always write to the end
> of the file. It wouldnt matter if another program wrote to the end
> while you where waiting for the lock. Am I correct on this?
Defense against broken systems. Personally I consider proper mail
delivery Very Important and think the code should be very defensive
against all problems.
> lock();
> print MBOX $msg,"\n\n";
> unlock();
For instance, this code does not check that the write to the
mailbox succeeded, nor does it flush before unlocking (needed
for old perl versions), and is consequently broken.
Elijah
------
disks fill up
------------------------------
Date: Fri, 19 Jan 2001 20:05:38 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How much time does a subroutine call take?
Message-Id: <m61a6.1120$B9.192882688@news.frii.net>
In article <94a25p$sq7$1@nnrp1.deja.com>, <tigra@sky.deep.ru> wrote:
>Hi.
>
>I've just got interested in benchmarking of sub calls in perl. To make
>the affairs worse I put the sub's code into a separate package and then
>eval it. So this is what I was going to test for my own purposes. The
>code follows:
>
>And does this mean that using
>for(...) {&code_that_says_blah_blah}
>instead of
>for(...) {blah-blah}
IMHO programming is more about communicating with the poor guy
that will have to maintain my code than about making the code fast
for the machine. There are a few cases where tight, highly optomized
solutions are appropriate but they are few and far between. In
those cases Perl is probably not your language of choice.
--
This space intentionally left blank
------------------------------
Date: Fri, 19 Jan 2001 21:30:08 GMT
From: metamp@my-deja.com
Subject: how to send a big file pipeing to sendmail
Message-Id: <94abki$647$1@nnrp1.deja.com>
I can not load a huge file to a $scalar
and I do not know a different way to send a big file useing send mail
the cat command would work I belive but do not know how to use itcan
anybody help with the syntax
this does not work
$sendmail ="/usr/lib/sendmail";
$myemail = 'henry@ttiorg.com';
open (dfile, "<file.txt");
flock (dfile,2);
$mail_body =<dfile>;
flock (dfile,8);
close dfile;
open (MAIL,"|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!
\n";
print MAIL "To: $myemail\n";
print MAIL "From: $sender\n";
print MAIL "Subject: the CGI datafile\n\n";
print MAIL "$mail_body";
close(MAIL) or die "Can't close pipe to $sendmail: $!\n";
the file is too large to by loaded to $scalar
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:07:05 GMT
From: simberg.interglobal@trash.org (Rand Simberg)
Subject: Re: MIME Lite Problem
Message-Id: <3a689cc6.69482201@nntp.ix.netcom.com>
On Fri, 19 Jan 2001 18:22:16 GMT, in a place far, far away,
simberg.interglobal@trash.org (Rand Simberg) made the phosphor on my
monitor glow in such a way as to indicate that:
>OK, I'm using MIME Lite, and am having a problem getting it to work.
>
>I put in the following debug statement:
>
> "About to set path to miguelruiz/dmrc_2001-01-18-131618.txt,
>contained in $data_directory/$file"
>
>just before setting
>
> Path => $data_directory/$file,
>
>There's another debug statement immediately following this one, but it
>doesn't print--the script seems to die there. The path is valid,
>because a different routine uses it successfully just before. Any
>ideas what the problem is?
Just as a follow up, in case I provided insufficient info, here's the
whole code snippet:
***************************************************
$msg = new MIME::Lite
From =>$mailer,
To =>$recipient,
# Cc =>$cc,
Subject =>'Contact Record Archive',
Type =>'multipart/mixed';
# Add parts (each "attach" has same arguments
as "new"):
attach $msg
Type =>'TEXT',
Data =>"The attached file contains
your requested archive backup.";
attach $msg
Type =>'text/plain',
# Encoding =>'quoted-printable',
print "About to set path to $data_directory/$file,
>contained in \$data_directory/\$file<p>";
Path =>$data_directory/$file,
print "Just got past Path parameter.<p>";
print "About to send mail<p>";
$msg->send;
*****************************************************
As I said, it prints "About to set path..." diagnostic, but doesn't
print the "Just got past Path parameter," leading my dim mind to
conclude that it had a problem with the path statement. Other than a
bad path, are there any other possibilities?
************************************************************************
simberg.interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
interglobal space lines * 307 733-1715 (Fax) http://www.interglobal.org
"Extraordinary launch vehicles require extraordinary markets..."
Replace first . with @ and throw out the "@trash." to email me.
Here's my email address for autospammers: postmaster@fbi.gov
------------------------------
Date: Fri, 19 Jan 2001 19:43:29 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: MIME Lite Problem
Message-Id: <BN0a6.1119$B9.192883712@news.frii.net>
In article <3a68847c.63263620@nntp.ix.netcom.com>,
Rand Simberg <simberg.interglobal@trash.org> wrote:
>OK, I'm using MIME Lite, and am having a problem getting it to work.
>
>I put in the following debug statement:
>
> "About to set path to miguelruiz/dmrc_2001-01-18-131618.txt,
>contained in $data_directory/$file"
>
>just before setting
>
> Path => $data_directory/$file,
>
My guess is that you are getting "Illegal division by zero".
Try putting quotes around your path construct.
--
This space intentionally left blank
------------------------------
Date: Fri, 19 Jan 2001 22:00:53 GMT
From: simberg.interglobal@trash.org (Rand Simberg)
Subject: Re: MIME Lite Problem
Message-Id: <3a6ab859.76542251@nntp.ix.netcom.com>
On Fri, 19 Jan 2001 19:43:29 GMT, in a place far, far away,
cfedde@fedde.littleton.co.us (Chris Fedde) made the phosphor on my
monitor glow in such a way as to indicate that:
>My guess is that you are getting "Illegal division by zero".
>Try putting quotes around your path construct.
DOH!
Good guess. It runs now, but it doesn't send the attachment...
******************************************************************
The contents of the email are:
Content-Disposition: inline
Content-Length: 57
Content-Transfer-Encoding: binary
Content-Type: text/plain
The attached file contains your requested archive backup.
*******************************************************************
Now how do I get it to actually do the attachment (see my code in my
other post in this thread)? It's just a tab-delimited database file.
************************************************************************
simberg.interglobal.org * 310 372-7963 (CA) 307 739-1296 (Jackson Hole)
interglobal space lines * 307 733-1715 (Fax) http://www.interglobal.org
"Extraordinary launch vehicles require extraordinary markets..."
Replace first . with @ and throw out the "@trash." to email me.
Here's my email address for autospammers: postmaster@fbi.gov
------------------------------
Date: 19 Jan 2001 21:20:10 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: MIME::Parser Finding decoded files
Message-Id: <eli$0101191559@qz.little-neck.ny.us>
In comp.lang.perl.misc, Drew Dowling <drewhead.nospam@drewhead.org> wrote:
> I'm writing a little program that will take a file sent via email (MIME
> attachments), decode the mail message to the file, and then do stuff
> with it. I've found MIME::Tools to be quite useful, specifically the
> MIME::Parser. I can easily receive and decode MIME attachments to a tmp
> dir. What I don't seem to be able to do is access the names of the
> files that my parser just created.
This is one of my complaints about MIME::Parser, too. My solution
was to use Data::Dumper to figure out where it stores the names
and just extract them from there. It isn't a good way, since that
could change between versions, but I suspect strongly that the next
MIME parser I use will be one I write (when I get enough tuits), so
I'm not worrying too much.
Here's my code with that big caveat:
print "Dumping <$file>\n";
my $entity = $parser->read(\*FILE) or
warn "$0: couldn't parse MIME stream ($file)\n";
&fn_output(\$entity);
...
sub fn_output ($) {
my $entity = shift;
my $i;
my $h;
for ($i = 0; $i < $$entity->parts; $i++ ) {
$h = $$entity->parts($i);
print "\t" .$$h{ME_Bodyhandle}{MB_Path} ."\n";
}
} # end &fn_output
> I'd rather not have to look in the tmp directory since I may have more
> than one iteration running at any given time, and I'd rather not bother
> building unique tmp dirs to hold all contents for the duration of the
> iteration.
I would do that, just to avoid mail clobbering files from other mail.
Elijah
------
already generates MIME messages on his own
------------------------------
Date: Fri, 19 Jan 2001 14:20:01 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: My hash slice is yielding a syntax error.. please help
Message-Id: <comdog-C50242.14200119012001@news.panix.com>
In article <lbsnmf749z.fsf@lnc.usc.edu>, Terrence Brannon
<brannon@lnc.usc.edu> wrote:
> The commented out line is yielding a syntax error. I was simply trying
> to create a hash slice. Why isn't it working? Thanks in advance.
slices begin with a @.
> #%H{@a} = {@a};
--
brian d foy <comdog@panix.com>
no longer for hire ;)
------------------------------
Date: 19 Jan 2001 13:11:54 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: My hash slice is yielding a syntax error.. please help
Message-Id: <m3g0ifjr0l.fsf@dhcp11-177.support.tivoli.com>
Terrence Brannon <brannon@lnc.usc.edu> writes:
> The commented out line is yielding a syntax error. I was simply trying
> to create a hash slice. Why isn't it working? Thanks in advance.
A hash slice would look like @H{@a}. One way to remember this is that
$ is for a single item (scalar), @ is for multiple items (array or
slice) and % is only for a full hash.
> use strict;
>
> my @a = qw(1 1 2 4 5);
>
> my %H;
>
> for my $a (@a) {
> $H{$a}++;
> }
>
> #%H{@a} = {@a};
In addition to the wrong syntax for the slice, you also have the wrong
syntax on the RHS -- you don't want those braces:
@H{@a} = @a;
> print join ':', keys %H;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 19 Jan 2001 22:31:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: My hash slice is yielding a syntax error.. please help
Message-Id: <x7k87rxjgk.fsf@home.sysarch.com>
>>>>> "TB" == Terrence Brannon <brannon@lnc.usc.edu> writes:
TB> The commented out line is yielding a syntax error. I was simply trying
TB> to create a hash slice. Why isn't it working? Thanks in advance.
others have corrected your code. learn more about hash slices at:
http://www.sysarch.com/perl/tutorials/hash_slices.txt
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 19 Jan 2001 19:40:58 GMT
From: data64 <data_64@my-deja.com>
Subject: Path env setting on Win32
Message-Id: <94a589$vrk$1@nnrp1.deja.com>
Is there a module or script to manipulate the PATH env variable on
win32. Especially on winnt and win2k where env variables are hidden in
the dungeons of the registry.
I figured I should check if someone has already done this before
beginning to do it myself.
Data64
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:52:59 GMT
From: Daniel Berger <djberg96@my-deja.com>
Subject: Re: Path env setting on Win32
Message-Id: <94a9f6$46d$1@nnrp1.deja.com>
I assume by this question, you mean permanately manipulate on the
machine, not just within your program. Otherwise, just use the Env
module.
For Win32 take a look at Win32::NetAdmin and Win32::AdminMisc. I think
both assume you have the privileges to do what you want. I'm not an
expert on these modules, or I'd offer more insight.
Hope that helps.
Regards,
Dan
In article <94a589$vrk$1@nnrp1.deja.com>,
data64 <data_64@my-deja.com> wrote:
> Is there a module or script to manipulate the PATH env variable on
> win32. Especially on winnt and win2k where env variables are hidden in
> the dungeons of the registry.
> I figured I should check if someone has already done this before
> beginning to do it myself.
>
> Data64
>
> Sent via Deja.com
> http://www.deja.com/
>
--
In the immortal words of Socrates, "I drank what?"
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 22:22:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl OOP questions
Message-Id: <x7n1cnxjwv.fsf@home.sysarch.com>
>>>>> "DO" == Darryl Olthoff <olthoff@multiboard.com> writes:
DO> I don't know of a way to pass a scalar after an array and have the
DO> function know that this is happening. That is not to say that it
DO> can't be done, I just don't know how to do it. I pass references
DO> to the arrany anyways....
sub foo {
my $bar = pop ;
my ( @array ) = @_ ;
}
of course this can't tell if you didn't pass in the scalar value.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 19 Jan 2001 23:51:57 +0100
From: "Jean-Michel Hiver" <jhiver@cisedi.com>
Subject: Re: Perl OOP questions
Message-Id: <94ah2r$88f$1@wanadoo.fr>
Hi,
The standard Perl module Data::Dumper has a 'deepcopy' method.
Thus, I should not be too hard to create a 'clone' method that returns
a deep copy of $self.
Cheers,
--
Jean-Michel Hiver - Software Engineer
http://cisedi.com - jhiver@cisedi.com
------------------------------
Date: Fri, 19 Jan 2001 21:10:04 -0000
From: "Ian Waters" <ian@ianwaters.com>
Subject: Re: Perl script problem
Message-Id: <94a9q0$3fl$1@newsg2.svr.pol.co.uk>
Please write out a 1000 times, "I must work on my people skills and try to
remeber that I do not own usenet."
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn96g9an.2q0.bernard.el-hagin@gdndev25.lido-tech...
> On 18 Jan 2001 08:46:23 +0000, nobull@mail.com <nobull@mail.com> wrote:
> >"Ian Waters" <ian@ianwaters.com> writes:
> >
> >> Subject: Perl script problem
> >
> >Please write out 1000 times: "I must not post to Usenet with
> >content-free subject lines".
>
> Change that to "Please write out 1000 times ON PAPER".
> It's too easy to do it electronically. :)
>
> Cheers,
> Bernard
> --
> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$
?] }'
------------------------------
Date: 19 Jan 2001 16:11:22 -0500
From: jdf@pobox.com
Subject: Re: Perl script problem
Message-Id: <u26vckn9.fsf@pobox.com>
"Ian Waters" <ian@ianwaters.com> writes:
> Please write out a 1000 times, "I must work on my people skills and try to
> remeber that I do not own usenet."
The guy helps you and guides you with humor, and you bite his hand.
Oops. *plonk*
My first kill!
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 19 Jan 2001 12:53:41 -0600
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: Perl Style Guide - uncuddled elses
Message-Id: <94a2fo$jfq@fidoii.CC.Lehigh.EDU>
<birgitt@my-deja.com> wrote:
> I am reading the Perl Style Guide and don't understand what the meaning
> of "uncuddled elses" is. What is meant by "uncuddled" ?
I took it to mean this:
# cuddled
}else{
#uncuddled
} else {
Phil R Lawrence
prlawrence@lehigh.edu
------------------------------
Date: Fri, 19 Jan 2001 20:41:05 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Style Guide - uncuddled elses
Message-Id: <slrn96h2hl.86m.tadmc@tadmc26.august.net>
Phil R Lawrence <prlawrence@lehigh.edu> wrote:
><birgitt@my-deja.com> wrote:
>> I am reading the Perl Style Guide and don't understand what the meaning
>> of "uncuddled elses" is. What is meant by "uncuddled" ?
>I took it to mean this:
>
># cuddled
>}else{
>
>#uncuddled
>} else {
Those are *both* cuddled (between curly braces).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 101
**************************************