[19776] in Perl-Users-Digest
Perl-Users Digest, Issue: 1971 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 20 21:05:31 2001
Date: Sat, 20 Oct 2001 18:05:08 -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: <1003626308-v10-i1971@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 20 Oct 2001 Volume: 10 Number: 1971
Today's topics:
Re: Filename case... (Martien Verbruggen)
Re: finding a string in a list (Tad McClellan)
Re: Fork messes up parent file handle? <andrew@erlenstar.demon.co.uk>
Re: Good Literature <tintin@snowy.calculus>
Re: Good Literature <uri@sysarch.com>
Re: Good Literature <tony_curtis32@yahoo.com>
Re: Good Literature <tony_curtis32@yahoo.com>
Re: How can I send an html formatted email, preferably <Juha.Laiho@iki.fi>
Re: http header for prompting Mac IE 5 downloading <tony_curtis32@yahoo.com>
Re: http header for prompting Mac IE 5 downloading <joe+usenet@sunstarsys.com>
Re: lookingglass.pl (Tad McClellan)
MacPerl: format STDOUT error (Travis Wilkins)
Re: namespaceproblem gives me a headache <goldbb2@earthlink.net>
Re: need Regular Expression help <pilsl_@goldfisch.at>
Re: need Regular Expression help (Alan Barclay)
newbie!!! weird mail::sender problem need help please!! (Vince)
Re: newbie!!! weird mail::sender problem need help plea <tony_curtis32@yahoo.com>
Re: newbie!!! weird mail::sender problem need help plea (Vince)
Re: requiring packages dynamically (Clinton A. Pierce)
Re: Scaling a DNA string <dtweed@acm.org>
Re: Scaling a DNA string <goldbb2@earthlink.net>
Re: Scaling a DNA string (Martien Verbruggen)
Re: taint unique to Perl? <Juha.Laiho@iki.fi>
Re: Tar failure with Pipe Open <goldbb2@earthlink.net>
Re: Truncation of array through reference <rog@stanford.edu>
Re: Writing and reading encrypted string (password) <Juha.Laiho@iki.fi>
Re: Writing to existing file (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 21 Oct 2001 09:57:17 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Filename case...
Message-Id: <slrn9t43qt.cnu.mgjv@martien.heliotrope.home>
On 20 Oct 2001 17:47:09 GMT,
Ilmari Karonen <iltzu@sci.invalid> wrote:
> In article <slrn9scel9.l88.mgjv@verbruggen.comdyn.com.au>, Martien Verbruggen wrote:
>>
>>the comparisons. However, there are semantic differences between the
>>two versions. The regex may miss out on capitalisation in certain
>>locales. I believe Finnish has some letters that could fall outside of
>>the A-Z range. A more equivalent, and locale-safe version would be
>
> Yes, just like German, French, Swedish, Danish, Norwegian, etc. -- in
> fact, most European languages have letters outside the A-Z range. And
> even if all you're processing is English, sooner or later someone will
> include a loanword like "cliché" in the text, with the accent intact.
Yes, most of these languages have letters that are not one of A-Z
(interpreted in english). However, AFAIK, thiose languages all collate
those extra letters between A and Z. I seem to recall in some way that
Finnish actually collates some extra letters after the Z, letters that
were imported from Swedish? Something like that. I don't know Finnish,
and if I'm wrong, then I'll just point to Greek, where [A-Z] would
certainly not mean 'all alphabetic uppercase characters'.
I wasn't trying to state that there were extra letters in other
languages, but that sometimes those extra languages order those letters
in such a way that A-Z and a-z don't include them.
I think that this just illustrates that [A-Z] should be used to express
this sort of thing, because I believe that you read it as 'all 26
characters in the English alphabet', while I read it as 'anything that
happens to fall between the uppercase letter A and the uppercase letter
Z in the current locale'. This can include lowercase characters, all
kinds of accented characters, and it could only be 10 or 20 characters,
all depending on how Perl handles this. Which brings us back to:
>>PS. According to perlre, [A-Z] is always a character class of 26
>>letters. Is this really true? Even if the collation of the characters
>>is someting like: A a B b C c D ..? perllocale is silent on this.
>
> It may or may not be explictly documented for the general case, but at
> least the EBCDIC ports are documented to treat purely alphabetic ranges
> as special cases. (Hmmm.. is that behavior locale-aware? I have no
> idea.) So I'd say yes.
Heh, that's funny. You have no idea, but you're still perfectly willing
to answer positively? :)
I would probably say: Since it isn't documented, I wouldn't count on
this behaviour to be correct. Since there are perfectly valid
alternatives to these character ranges, I would advice people to use
them. Use [:upper:] when you mean all uppercase characters. Use
[:alpha:] when you mean all alphabetic characters, etc. it is more
correct than [A-Z] and [A-Za-z], and no less clear. One could argue that
it is more clear that one intended to use _all_ uppercase alphabetics,
instead of just the ones between A and Z.
Martien
--
|
Martien Verbruggen | I took an IQ test and the results
| were negative.
|
------------------------------
Date: Sat, 20 Oct 2001 22:08:56 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: finding a string in a list
Message-Id: <slrn9t3p2u.2fg.tadmc@tadmc26.august.net>
Donato <allistante@zzzhotmailzzz.com> wrote:
>"Tad McClellan" <tadmc@augustmail.com> ha scritto nel messaggio
>news:slrn9t3jci.2cs.tadmc@tadmc26.august.net...
>> Donato <allistante@zzzhotmailzzz.com> wrote:
>>
>> >can anyone tell me if there is a short way to find a string in a list?
>> Use the grep() function when you want to "filter a list":
>>
>> my @list = grep /stringa/, @big_list_to_filter;
>In perlfaq4 I have found this:
>
>...
> Please do not use
>
> ($is_there) = grep $_ eq $whatever, @array;
>
> or worse yet
>
> ($is_there) = grep /$whatever/, @array;
Yes, I knew that.
You asked how to "find a string in a list".
But I showed (the more general) how to "filter a list".
Your question is a FAQ. If you had wanted a _good_ answer you
would have checked the FAQ before posting. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Oct 2001 00:54:04 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: Fork messes up parent file handle?
Message-Id: <87pu7hhnqb.fsf@erlenstar.demon.co.uk>
>>>>> "John" == John English <je@brighton.ac.uk> writes:
John> Why should forking a child affect the parent's copy of a file
John> handle?
Because while the file _descriptor_ is copied, the underlying open
file reference (which includes the current file position) is _shared_,
not copied. If the child does anything that causes lseek() to be
called on the file, then the parent will become confused (because its
idea of where the position should be will no longer match reality).
--
Andrew.
------------------------------
Date: Sun, 21 Oct 2001 08:15:01 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Good Literature
Message-Id: <PImA7.3$BY4.189609@news.interact.net.au>
"mike w" <no_spam@none.com> wrote in message
news:3bd1d20f$1@news.peakpeak.com...
>
> Geoff Clark <gclark@wavetel.com> wrote in message
> news:LhjA7.831003$NK1.74319411@bin3.nnrp.aus1.giganews.com...
> > Can anyone suggest any good literture on wirting CGI Scripts. This is
> what
>
> www.cgi101.com Great place to begin.
I had a quick look through the first 6 chapters. It contains a reasonable
amount of incorrect information and bad programming habits.
------------------------------
Date: Sat, 20 Oct 2001 22:49:11 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Good Literature
Message-Id: <x7hesu3p0v.fsf@home.sysarch.com>
>>>>> "T" == Tintin <tintin@snowy.calculus> writes:
T> "mike w" <no_spam@none.com> wrote in message
T> news:3bd1d20f$1@news.peakpeak.com...
>>
>> Geoff Clark <gclark@wavetel.com> wrote in message
>> news:LhjA7.831003$NK1.74319411@bin3.nnrp.aus1.giganews.com...
>> > Can anyone suggest any good literture on wirting CGI Scripts. This is
>> what
>>
>> www.cgi101.com Great place to begin.
T> I had a quick look through the first 6 chapters. It contains a
T> reasonable amount of incorrect information and bad programming
T> habits.
GACK!!
You can edit your Perl scripts either on your local machine
(using your favorite text editor - Notepad, Simpletext, etc.),
or in the Unix shell. If you're using Unix, try pico - it's a
very simple, easy to use text editor. Just type pico filename to
create or edit a file.
how many unix boxes have pico installed by default? who edits files in
the shell?
Most lines of Perl code must end in a semicolon (;), except the
opening and closing lines of loops and conditional blocks. We'll
cover those later.
wow, that is so wrong, i have trouble even reading it and not poking out
my eyes.
@colors = ("green", "blue", "cyan", "magenta", "black");
sort(@colors) # sorts the values of @colors
# alphabetically
@colors now becomes ("black", "blue", "cyan", "green", "magenta"
). Note that sort does not change the actual values of the array
itself, so if you want to save the sorted array, you have to do
something like this:
@sortedlist = sort(@colors);
so WHY even show the sort in a void context? first he says sort changes
@colors and then he says it doesn't.
i can't go on reading this. please don't recommend this site to anyone.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 20 Oct 2001 18:19:45 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Good Literature
Message-Id: <87d73h527i.fsf@limey.hpcc.uh.edu>
>> On Sat, 20 Oct 2001 22:49:11 GMT,
>> Uri Guttman <uri@sysarch.com> said:
>>> www.cgi101.com Great place to begin.
> i can't go on reading this. please don't recommend this
> site to anyone.
It gets worse, viz.
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
Yikes! I bet most people here can guess what code comes
next...
Oh. It does get much worse. "chmod 666". OK, I give up
too...
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Sat, 20 Oct 2001 18:22:55 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Good Literature
Message-Id: <878ze55228.fsf@limey.hpcc.uh.edu>
>> On Sat, 20 Oct 2001 22:49:11 GMT,
>> Uri Guttman <uri@sysarch.com> said:
>>> www.cgi101.com Great place to begin.
"telnet" (telnet? There's a problem before we even start
on CGI) screenshot, introduction chapter. The login name
says it all.
The entire thing is appalling.
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: 20 Oct 2001 09:16:27 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: How can I send an html formatted email, preferably using Net::SMTP?
Message-Id: <9qrfdb$5qt$2@ichaos.ichaos-int>
"Jon Feldhammer" <jonf@rgb.com> said:
>I'm having a very hard time sending an email that a html enabled mail
>program will read as html. I assume it has to do with the header line
>Content-Type: text/plain which needs to be Content-Type: text/html ... I
>can't seem to figure out how to change that line, or maybe that isnt' the
>problem.
Hmm.. is this what you seek? For more info on header syntax (how to
format "From:" and "To:" lines), check RFC2822. Perhaps Mail::Header
could be used as well, but I don't seem to have it installed on my
system and this wasn't too much code to write by hand anyway.
#!/usr/local/bin/perl -w
use Net::SMTP;
$smtp = Net::SMTP->new('mailhost.invalid');
$smtp->mail('sender@origin.invalid');
$smtp->to('recipient@dest.invalid');
$smtp->data();
$smtp->datasend("From: sender\@origin.invalid\n");
$smtp->datasend("To: recipient\@dest.invalid\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: text/html\n");
$smtp->datasend("Subject: Topic\n");
$smtp->datasend("\n");
$smtp->datasend("<html><body><strong>Content here</strong></body></html>\n");
$smtp->dataend();
$smtp->quit;
exit;
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 20 Oct 2001 17:15:27 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: http header for prompting Mac IE 5 downloading
Message-Id: <87itda556o.fsf@limey.hpcc.uh.edu>
>> On 20 Oct 2001 15:04:23 -0700,
>> jamesliu@sprynet.com (James Liu) said:
> I am currently doing a project that allows the client to
> download files from a site. So basically I return the
> content of the file with the following HTTP header:
> Content-Type: application/force-download
> Content-Disposition: attachment; filename="<attachment>"
> Content-Transfer-Encoding: binary Content-Length:
> <length>
> It worked fine for both IE and Netscape on Windows, and
> Netscape for Mac, but I just can't get IE5 for Mac to
> work with this piece of code.. I have tried so many
> variations to the header, but nothing worked.
> I would appreciate any help that I can get!
Try a newsgroup that is relevant to your problem?
E.g. one with www in its name.
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: 20 Oct 2001 18:21:10 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: http header for prompting Mac IE 5 downloading
Message-Id: <m3n12m7y21.fsf@mumonkan.sunstarsys.com>
jamesliu@sprynet.com (James Liu) writes:
> I am currently doing a project that allows the client to download
> files from a site. So basically I return the content of the file
> with the following HTTP header:
>
> Content-Type: application/force-download
> Content-Disposition: attachment; filename="<attachment>"
> Content-Transfer-Encoding: binary
> Content-Length: <length>
>
> It worked fine for both IE and Netscape on Windows, and Netscape
> for Mac, but I just can't get IE5 for Mac to work with this piece
> of code.. I have tried so many variations to the header, but
> nothing worked.
>
> I would appreciate any help that I can get!
"Mu."
--
Joe Schaefer "Verbosity leads to unclear, inarticulate things."
-- Dan Quayle
------------------------------
Date: Sat, 20 Oct 2001 22:08:57 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: lookingglass.pl
Message-Id: <slrn9t3pk0.2fg.tadmc@tadmc26.august.net>
Steffen Müller <tsee@gmx.net> wrote:
>"Tad McClellan" <tadmc@augustmail.com> schrieb im Newsbeitrag
>news:slrn9t17in.v1c.tadmc@tadmc26.august.net...
>
>[snip]
>
>| 3) uses scalar(@array)-1 instead of $#array ( $#{$local_files[1]} )
>
>Though I generally agree with you that the program isn't well written, I
>recall there being some discussion
Here?
Got any search term that might help me find the thread you
are thinking of?
>about the use of $#{} versus @{}-1. IIRC,
>there are a bunch of not-so-bad programmers out there who use @array-1.
That isn't too helpful unless you present some reason why
it is "better".
So, I'll present a reason why (I think) $# might be better [1]:
You don't have to ensure scalar context as you do with @
How is @array-1 "better" than $#array ?
[1] And that isn't even my "primary reason". The primary reason to
use $#array instead of @array-1 is that it more clearly
communicates what is meant:
$#array = index of the last element
@array - 1 = size of array minus one
I don't want to have to figure out that "size of array minus one"
is the same as "index of the last element". If I want the last
index I use $#array.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 20 Oct 2001 17:23:31 -0700
From: twilk1158@my-deja.com (Travis Wilkins)
Subject: MacPerl: format STDOUT error
Message-Id: <b6177f54.0110201623.279c0063@posting.google.com>
Does MacPerl not do formatting?
example:
format STDOUT =
@<<<< @<<<< @<<<<
$a, $b, $c
.
gives me the error of: #Format not terminated, at end of line
What should I be doing to get formatting?
------------------------------
Date: Sat, 20 Oct 2001 20:19:54 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: namespaceproblem gives me a headache
Message-Id: <3BD214AA.D9FDCC66@earthlink.net>
peter pilsl wrote:
>
> I have two modules and each of them require each other. So I end up
> with big problem that I dont understand .. (I expected it, but I dont
> understand it)
> The following modules and testscript reproduces my problem. Of course
> m2 isnt really needed in m1 in that test-modules but it shows the
> effect ...
This just came up very recently on comp.lang.perl.modules. See the
thread labeled "Re: Why BEGIN block in perlfaq7 around initial package
code?"
Anyway, to fix this problem, change your code to:
package test::m1;
require 5.005_62;
use strict;
use warnings;
use Exporter ();
BEGIN {
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(m1);
#our @EXPORT = qw(m1);
our $VERSION = '0.01';
}
use test::m2 qw(m2);
sub m1 { 'm1' }
1;
__END__
package test::m2;
require 5.005_62;
use strict;
use warnings;
use Exporter ();
BEGIN: {
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(m2);
#our @EXPORT = qw(m2);
our $VERSION = '0.01';
}
use test::m1 qw(m1);
sub m2{
my $a=m1();
return $a.'m2';
};
1;
__END__
[snip]
> I dont understand cause I imported m1 ...
No, you didn't.
The way it works is this:
in test.pl
require test::ml; # first part of the 'use'. Begins loading test/m1.pm
in test::ml
require test::m2; # first part of the 'use'. Begins loading test/m2.pm
in test::m2
require test::m1; # first part of the 'use'. Noop since m1.pm is loaded
test::ml->import("m1") if test::ml->can("import")
# the above line is the second part of the 'use' from within m2.pm
# since at this point in time, m1.pm HAS NOT required Exporter, nor set
# @ISA, or @EXPORT_OK, etc, test::ml->can("import") returns undef, so
# of course test::m2 imports nothing from test::m1.
> All packages have their own namespace so there should be no collision
> even if the modules imports each other.
That's not the problem. The problem is in what order various things
occur.
> I just import m1 from module m1 ...
You *think* you're importing m1, but you're not.
Maybe perl should print out a warning if arguments are passed to the
'use' line and there is no "import" method defined in the package.
> my head is calming and maybe I dont see the obvious ...
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Sun, 21 Oct 2001 01:59:18 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: need Regular Expression help
Message-Id: <3bd20ff5@e-post.inode.at>
Brian Janko wrote:
> I just found the spot in my code where I am allowing the spaces through,
> so the problem has becoem a moot point.
>
so it was not the code you shared with us ?
best,
peter
--
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: 21 Oct 2001 00:08:12 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: need Regular Expression help
Message-Id: <1003622891.988576@elaine.furryape.com>
In article <3BD0F532.6C8805EC@acm.org>, Dave Tweed <dtweed@acm.org> wrote:
>Brian Janko wrote:
>> However, you bring up a good point. I did not know there was an "official"
>> standard for valid email addresses. Where would I find that spec? I would
>> be very interested.
>
>It's called RFC822. Any search engine should be able to dig up a copy for you.
Actually, RFC822 was made obsolete by RFC2822 earlier this year.
------------------------------
Date: 20 Oct 2001 15:15:55 -0700
From: zambak76@yahoo.com (Vince)
Subject: newbie!!! weird mail::sender problem need help please!!!!
Message-Id: <c85db9d8.0110201415.21d580ea@posting.google.com>
Hi!
I'm having this weird problem with the mail::sender module. I wrote a
script that uploads and emails a file. The script uploads the file
fine, but somehow it doesn't e-mail it all the times. At first I
thought it was the perl version I was running on which was 5.005, the
reason I thought that was because I had installed the script on
another server which had the same O/S (Linux) but with perl 5.6 and
the script worked each time. So I upgraded perl to 5.6 and I still had
the same probelm, whenever the script feels like sending an e-mail it
does. I have no clue!!!! The one other difference between the server
that the script is working on and the one that's not is that they have
different smtp servers, the one that works on I think uses a microsoft
exchange server and the one that sometimes works uses EXIM ???? I read
in the mail::sender documentation that mail::sender doesn't work with
qmail. Is exim and qmail the same ??? I really don't know if they are
or not and have no idea on how to debug this problem.
Any help is much apreciated!!!!
Thanks
------------------------------
Date: Sat, 20 Oct 2001 17:41:10 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: newbie!!! weird mail::sender problem need help please!!!!
Message-Id: <87elny53zt.fsf@limey.hpcc.uh.edu>
>> On 20 Oct 2001 15:15:55 -0700,
>> zambak76@yahoo.com (Vince) said:
> Hi! I'm having this weird problem with the mail::sender
> module. I wrote a script that uploads and emails a
> file. The script uploads the file fine, but somehow it
> doesn't e-mail it all the times.
There's a problem.
No code + no details == no meaningful help.
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: 20 Oct 2001 18:03:19 -0700
From: zambak76@yahoo.com (Vince)
Subject: Re: newbie!!! weird mail::sender problem need help please!!!!
Message-Id: <c85db9d8.0110201703.1952d41@posting.google.com>
Tony Curtis <tony_curtis32@yahoo.com> wrote in message news:<87elny53zt.fsf@limey.hpcc.uh.edu>...
> >> On 20 Oct 2001 15:15:55 -0700,
> >> zambak76@yahoo.com (Vince) said:
>
> > Hi! I'm having this weird problem with the mail::sender
> > module. I wrote a script that uploads and emails a
> > file. The script uploads the file fine, but somehow it
> > doesn't e-mail it all the times.
>
> There's a problem.
>
> No code + no details == no meaningful help.
>
> hth
> t
So True!! Here's the script:
#!/usr/bin/perl -Tw
#require 5.001;
use strict;
require "./cgi-lib.pl";
use Mail::Sender;
MAIN:
{
my (%cgi_data, %cgi_cfn, %cgi_ct, %cgi_sfn, $ret, $buf );
# When writing files, several options can be set..
$cgi_lib::writefiles = "/tmp";
# Limit upload size to avoid using too much memory
$cgi_lib::maxdata = 500000;
$ret = &ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);
if (!defined $ret)
{
&CgiDie("Error in reading and parsing of CGI input");
}
elsif (!$ret)
{
&CgiDie("Missing parameters\n",
"Please complete the form ",
"<a href='www.testing.com/upload.html'>",
"upload.html</a>\n");
}
elsif (!defined $cgi_data{'upfile'} )
{
&CgiDie("Data missing\n", "Please specify a file\n");
}
rename "$cgi_data{'upfile'}","$cgi_lib::writefiles/$cgi_cfn{'upfile'}";
my $newPerm = '0777';
my $mode = oct($newPerm);
my $uploadFile = "/tmp/$cgi_cfn{'upfile'}";
chmod $mode, $uploadFile;
my $sender;
my $compName = " Company Name: $cgi_data{'compname'}";
my $contact = " Contact Name: $cgi_data{'contactname'}";
my $phone = " Phone Num: $cgi_data{'phonenum'}";
my $fax = " Fax Num: $cgi_data{'fax'}";
my $emailAddr = "Email Address: $cgi_data{'retemail'}";
my $instrCom = "Instruction-Commentse: $cgi_data{'instruct'}";
ref ( $sender = new Mail::Sender { from => 'script@testing.com',
smtp => 'mail.testing.com',
boundary => 'This-is-a-mail-boundary-435427'})
or die "Error($sender) : $Mail::Sender::Error\n";
$sender->OpenMultipart({to => 'testing@testing.com',
subject => 'File Uploaded'});
$sender->Body;
$sender->SendLine($compName);
$sender->SendLine($contact);
$sender->SendLine($phone);
$sender->SendLine($fax);
$sender->SendLine($emailAddr);
$sender->SendLine;
$sender->SendLine($instrCom);
$sender->SendFile({description => 'Uploaded file',
ctype => $cgi_ct{'upfile'},
encoding => 'Base64',
disposition => 'attachment; filename="Uploaded
File"; type="gif"', file => $uploadFile });
$sender ->Close;
unlink ($uploadFile) or
&CgiError("Error: Unable to delete file",
"Error: Unable to delete file $uploadFile: $!\n");
$cgi_lib::writefiles = $cgi_lib::writefiles;
$cgi_lib::maxdata = $cgi_lib::maxdata;
}
------------------------------
Date: Sat, 20 Oct 2001 22:17:29 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: requiring packages dynamically
Message-Id: <ZJmA7.187315$K6.90392829@news2>
[Posted and mailed]
In article <Pine.LNX.4.10.10110201355140.7528-100000@gloria.cam.org>,
Marc Tardif <intmktg@gloria.cam.org> writes:
> Is there a portable way to require a package after
> building its name dynamically? For example:
>
> foreach (qw(Foo Bar)) {
> my $package = "One::Two::$_";
> require $package;
> }
>
> The problem with the above is that since $package
> is a scalar, require expects an explicit path to
> the package name so I'd have to declare $package
> as:
>
> my $package = "/path/One/Two/$_.pm";
>
> Unfortunately, this is not portable and rather
> limited compared to letting Perl use the @INC
> array. So is there a way around this problem?
My, my. You're asking an awful lot of questions today that are
in the manual. Almost exactly as you've asked them. For this one
read up on require:
perldoc -f require
And there's a re-asking of your question, an explanation, and a
suggested answer (or two!).
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sat, 20 Oct 2001 22:25:06 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Scaling a DNA string
Message-Id: <3BD1F857.339CB2AB@acm.org>
DocDodge wrote:
> Here is what that might look like when done:
>
> --------G--------------------G---------- gene A
> ----------------CG--G------------------- gene B
> ---------------G-G-C--C----------------- gene C
> -----------G---------------------------- gene D
> ---------------------------------------- gene E
> --C------------------------------------- gene F
> ---------------GGG--C--G------------G--- gene G
> ---------------------------------------- gene H
> -----------C---------------------------- gene I
>
> Some wonder what exactly defines a motif. Is it GGGG or GGGGG and is
> GGGGGGGG one motif or two. The answer is flexible. Eight G's in a row is
> certainly two motifs; four G's is one motif. Between 4 and 8 could be one
> or two motifs, whatever is easier to implement. I've been calling it one
> motif for now.
OK, let me take my previous attempt, fix the definition of motif and
generate the above output format using linear scaling (instead of
logarithmic).
# split the sequence into motifs and non-motifs
# all of the odd positions in this array will be motifs
@m = split /(C{4}|G{4})/, $sequence;
# Count the motifs so we can account for the spot each one occupies.
my $mcount = int (@m/2);
# add up the total length of non-motifs so we can get an appropriate
# scale factor to produce a 40-character output line.
my $count = (length $sequence) - 4 * $mcount;
my $line = 40;
for (0..$#m) {
if ($_ % 2) {
# motif - print one character
print chop $m[$_];
--$mcount;
--$line;
} else {
# non-motif - select a relative length based on the length
# of the string and the number of spaces remaining on the line
my $scale = ($line - $mcount) / $count;
my $len = length $m[$_];
my $x = int ($len * $scale);
print '-' x $x;
$count -= $len;
$line -= $x;
}
}
print "\n";
-- Dave Tweed
------------------------------
Date: Sat, 20 Oct 2001 20:36:52 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Scaling a DNA string
Message-Id: <3BD218A4.5FD602BD@earthlink.net>
Dave Tweed wrote:
[snip]
> OK, let me take my previous attempt, fix the definition of motif and
> generate the above output format using linear scaling (instead of
> logarithmic).
Your code only scales the non-motifs... this is ok if they are very
sparse, but can produce strangely wrong output with some data. Suppose
we are scaling 2000 characters to 50 characters, which should be a 40:1
ratio. Now suppose the last 5 blocks are *full* of motifs, and there
are none anywhere in the rest of the DNA. This produces an output
string of 50 Cs or Gs, with no -s. If there are more than 50 motifs,
it's even worse -- your output will be more than 50 characters wide.
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Sun, 21 Oct 2001 10:51:37 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Scaling a DNA string
Message-Id: <slrn9t470p.cnu.mgjv@martien.heliotrope.home>
On Sat, 20 Oct 2001 21:04:31 GMT,
Andrew Cady <please@no.spam> wrote:
>
> [Snip discussion on representing long strings of genetic code using
> ASCII text]
>
> I have to wonder, is there a specific reason you're limited to ASCII
> text here? It seems the best and easiest solution would involve some
> form of pixel-based graphics, if available. It is inherently
> difficult to represent a lot of information in a little space at bad
> resolution. Is it possible just to increase the resolution?
Very interesting idea. The following may be a first shot at it:
use strict;
use GD;
# chart_motifs( $gene [, file_name, chart_width, bar_height, bar_spacing ]
#
# Chart a gene, highligting motifs. All uninteresting bits will be gray,
# C motifs will be blue, and G motifs red. The gene will visually be
# broken up in segments of $width bases long.
#
my $FILENUM;
sub chart_motifs
{
my $gene = shift;
my $file = shift || "gene" . ++$FILENUM . ".png";
my $nbase = length $gene;
my $width = shift || 800;
my $bar_height = shift || 5;
my $bar_space = shift || int($bar_height/2);
my $nbars = int($nbase/$width) + ($nbase%$width ? 1 : 0);
my $height = $nbars * $bar_height + ($nbars - 1) * $bar_space;
my $gd = GD::Image->new($width, $height);
$gd->colorAllocate(255, 255, 255);
my $gcol = $gd->colorAllocate(255, 0, 0);
my $ccol = $gd->colorAllocate( 0, 0, 255);
my $gray = $gd->colorAllocate(127, 127, 127);
# lowercase all motifs
$gene =~ s/(C{4,}|G{4,})/lc $1/ge;
# If a motif has to be 4 characters precisely, use this instead:
#$gene =~ s/(C{4}|G{4})/lc $1/ge;
my ($x, $y) = (0, 0);
while ($gene =~ /(.)/g)
{
my $clr = $1 eq 'c' ? $ccol
: $1 eq 'g' ? $gcol
: $gray;
$gd->line($x, $y, $x, $y + $bar_height - 1, $clr);
$x++;
if ($x >= $width)
{
$x = 0;
$y += $bar_height + $bar_space;
}
}
open my $gdh, ">$file" or die "Cannot open $file for write: $!";
binmode $gdh;
print $gdh $gd->png;
}
A more clever approach would indent all the bars, except the first one a
bit, to make it visually a bit clearer that they're continuations. And
maybe a little program should output a ruler image. That way the images
could all be wrapped up (automatically) in a HTML page, and loaded in a
webby browser, with the name of the gene next to the appropriate image,
etc.. etc...
Martien
--
|
Martien Verbruggen | Useful Statistic: 75% of the people
| make up 3/4 of the population.
|
------------------------------
Date: 20 Oct 2001 09:48:56 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: taint unique to Perl?
Message-Id: <9qrha8$5qt$4@ichaos.ichaos-int>
efflandt@xnet.com said:
>One reason that Perl has taint checking available is because it can
>potentially be run suid as another user (suidperl) and you want to be
>certain of the integrety of any input. Most systems will not honor suid
>for any other type of scripting (just compiled binaries).
And another place where input comes from an untrusted source (and the
script is running with a different set of access rights than those
the accessing user has on the executing machine) are all kinds of
network daemons. The most visible in this category are CGI scripts.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 20 Oct 2001 19:52:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Tar failure with Pipe Open
Message-Id: <3BD20E3B.958073CC@earthlink.net>
What A Man ! wrote:
>
> Benjamin Goldberg wrote:
> >
> > BUCK NAKED1 wrote:
> > >
> > > I had forgot that Ben recommended using a pipe for testing tar.
> >
> > I mentioned it was possible, I didn't *recommend* it.
>
> Sorry, bad choice of words. I should've said "suggested" it.
> >
> > > He also recommended using a filetest operator, but I couldn't get
> > > that to work.
> >
> > What do you mean when you say that it didn't work?
>
> That's Tad favorite saying.:) Anyway, I was afraid someone would ask
> that. I tried something like if (-z TEST>) { print "FAILURE" } and
> it always failed. I probably have the syntax wrong.
The expression (-z <TEST>) reads a line from the filehandle TEST, and
applies the -z operator to it.
> > > I decided to just test success based on retrieving a list of
> > > files (-t) and later exec tar based on that. Is the coding below
> > > OK? It seems to work.
> > >
> > > open( TEST, "tar -ztf $tmpfile |" );
> > > if ( <TEST> eq "" ) {
> > > print "Tar TEST Failed!\n";
> > > close TEST; exit;
> > > };
> >
> > Sure, I guess it may work, but it doesn't give you the ability to
> > seperately learn the success or failure of the gunzip and tar
> > operations.
>
> I understand. I had a feeling, that I would need to separate the
> procedures and do the gunzip separately. I guess that's the difference
> between my elementary code and your collegiate example. :)
>
> > The way *I* would do it, would be:
> >
> > use IPC::Open2;
> >
> > open( TMPFILE, "<$tmpfile" )
> > or die "Couldn't open $tmpfile for reading: $!";
> >
> > my $g_pid = open2(FROM_GUNZIP, "<&TMPFILE", "gunzip", "-c", "-d");
> > my $t_pid = open2(FROM_TAR, "<&FROM_GUNZIP", "tar", "tf", "-");
> >
> > if( my @tar_output = <FROM_TAR> ) {
> > print "Success! The tar file contains the following:\n";
> > print @tar_output;
> > } else {
> > print "Failure!\n";
> > print "Either the tar file empty, or something screwed up.\n";
> > }
> >
> > if( waitpid $g_pid, 0 ) {
> > my ($sig, $ret) = ($? & 255, $? >> 8);
> > die "gunzip died from signal $sig" if $sig;
> > die "gunzip exited with code $ret" if $ret;
> > } else {
> > die "Somebody musta reaped my gunzip process: $!";
> > }
> >
> > if( waitpid $t_pid, 0 ) {
> > my ($sig, $ret) = ($? & 255, $? >> 8);
> > die "tar died from signal $sig" if $sig;
> > die "tar exited with code $ret" if $ret;
> > } else {
> > die "Somebody musta reaped my tar process: $!";
> > }
> >
> > END: {
> > kill SIGKILL => $g_pid, $t_pid;
> > }
> > __END__
> >
> Looks great. Why am I getting "gunzip exited with code 1 at
> /home/public_html/untarpost.cgi line 49, <FROM_TAR> chunk 10?"
It means that gunzip used "exit(1);" to exit. Generally, this means
that the program failed for some reason for other. According to my man
page for gunzip:
DIAGNOSTICS
Exit status is normally 0; if an error occurs, exit status is 1.
If a warning occurs, exit status is 2.
My, how helpful :p There appears no way to tell *what kind* of error
occurred.
See what happens if you replace
"gunzip", "-c", "-d"
with either:
"gunzip", "-c"
or:
"gzip", "-c", "-d"
Also, for any of these, try adding a "-v" option, for verbose output --
hopefully it's smart enough to print diagnostics to stderr when the
regular output is going to stdout.
> ... and do I really need that END block?
Well, if either child process fails for some reason or other, you want
to kill both of them. Otherwise, they might continue running after
their parent process exits. For example, if fork when we call open2 for
tar, it will die... gunzip would keep running unless we kill it, and
it's easier to add an END block than to wrap the code in an eval.
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Sat, 20 Oct 2001 15:24:28 -0700
From: Roger Levy <rog@stanford.edu>
Subject: Re: Truncation of array through reference
Message-Id: <Pine.GSO.4.33.0110201518010.3994-100000@elaine8.Stanford.EDU>
On Fri, 19 Oct 2001, Tad McClellan wrote:
> Roger Levy <rog@stanford.edu> wrote:
> >Hi friends,
> >
> >I discovered what is to me a pretty non-intuitive fact just now, and I was
> >wondering about the explanation. I was trying to do array truncation
> >through references, and it turns out that if I have @ARRAY, and $A points
> >to it, then
> >
> >$#$A,
>
> access via a reference ( a special case of $#{$A} )
>
> >$#ARRAY,
>
> access via a name
>
> > and $#{\@ARRAY}
>
> access via a reference
>
>
> >are the same thing. To me this was pretty non-intuitive, since ARRAY
> >can't be used equivalently to \@ARRAY in general.
>
>
> @ARRAY can be used equivalently to @{\@ARRAY} or @{$A} or @$A.
>
> They are applications of "Use Rule 1" in
>
> perldoc perlreftut
>
> s/\@/$#/ for all 4 above, and you have the same as your examples.
>
> >So should I think of
> >the above as
> >
> >I) not being able to use ARRAY as a reference to @ARRAY is a special fact;
>
> ARRAY is a bare word. It is not associated with ANY variable,
> so I don't follow that one...
>
> >II) being able to use $#ARRAY as $#{\@ARRAY} is a special fact;
>
> the first is accessing via a name, the second is accessing
> via a reference.
>
>
> >III) something more complicated is going on?
>
> There are two ways of "getting to" a variable, via a name or
> via a reference.
Yes, this I understand. So would I be correct to say that @ and $# as
symbols are overloaded between dereferencing and name lookup?
Thanks for the reply,
Roger
------------------------------
Date: 20 Oct 2001 09:40:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Writing and reading encrypted string (password)
Message-Id: <9qrgpg$5qt$3@ichaos.ichaos-int>
Bart Lateur <bart.lateur@skynet.be> said:
>Both base64 and UU-encoded look far too familiar to any computer
>literate. They'd be tempted to decode it, just for the heck of it.
For me at least it'd be more like "this looks like Unix crypt() or
the MD5 password-hash, which are too much trouble", or "oh, base64 or
uu-coded, so someone's been friendly enough to transform the plaintext
to something human-unreadable". If it's something else, esp. when the
accessing program is written in some non-compiled language, I might even
be curiuos enough to see what the algorithm is, and whether it is
reversible. Especially so, if the password string lengths differ; this
would indicate that the "encryption" is just some letter-transformation.
So, make a difference between the three techniques:
- secure, one-way password hash algorithms designed to protect
authentication tokens on server end
- cleartext password obfuscation designed to prevent accidental
disclosure/viewing of passwords either on client end or on
some kind of proxy system
- password silo protected by a strong encryption method requiring
an access password and/or a hardware token (this again either on
client end or on a proxy system)
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 20 Oct 2001 22:08:58 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Writing to existing file
Message-Id: <slrn9t3qma.2fg.tadmc@tadmc26.august.net>
Neal E. Coombes <Neal.Coombes@telus.net> wrote:
>$ch =~ /FROM=([^&]+)/; # find the URL for refering page
>$from = $1; # store it in $from
Never ever use the dollar-digit variables without first checking
to see if the pattern match succeeded. The dollar-digit variables
are not changed when a match fails.
Consider:
-------------------------------
#!/usr/bin/perl
use warnings;
use strict;
$_ = 'wilma and betty';
/(wilma)/; # successful match
#
# imagine that there are 1000 lines of code here...
#
my $ch = 'FROM=';
$ch =~ /FROM=([^&]+)/; # failed match
my $from = $1;
print "$from\n"; # prints wilma
-------------------------------
You're going to wonder how the heck 'wilma' got into $from.
How long will it take you to find that it came from a thousand
lines earlier? Probably a Long Time.
If you are "sure" that it will match, then it should be a fatal
error if it does not match:
die "could not match '$ch'" unless $ch =~ /FROM=([^&]+)/;
my $from = $1; # match must have succeeded if we get here
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 1971
***************************************