[17615] in Perl-Users-Digest
Perl-Users Digest, Issue: 5035 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 5 09:05:33 2000
Date: Tue, 5 Dec 2000 06:05:13 -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: <976025112-v9-i5035@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 5 Dec 2000 Volume: 9 Number: 5035
Today's topics:
Re: -T & cgi security help with code! (Abigail)
Re: adduser <Per-fredrik.Pollnow@epk.ericsson.se>
Re: adduser <josef.moellers@fujitsu-siemens.com>
Re: array of unique random numbers (Abigail)
Re: array of unique random numbers <joe+usenet@sunstarsys.com>
Re: array of unique random numbers (Anno Siegel)
DBI insert problem <john@imining.com.tw>
fetch by array eastking@my-deja.com
Re: Help with /\d+\s*(S+)/ Please <lincmad001@telecom-digest.zzn.com>
Re: Help with getting an array (Anno Siegel)
Re: how to do Https:// through perl ? <mtx064@coventry.ac.uk>
Re: kill and security (suid) <rick.delaney@home.com>
learning perl, this does not work ... why? (Anno Siegel)
Re: Lost in a sea of obfuscation... <iltzu@sci.invalid>
Re: Question: How to Return script name from within scr <David.Hiskiyahu@alcatel.be>
Re: references, hashes & arrays <iltzu@sci.invalid>
Re: sending attachments with email <hermann_fass@hotmail.com>
Re: sending attachments with email <hermann_fass@hotmail.com>
Serial module <livia74@ctimail3.com>
Re: Sorting the result of a function <W.Hielscher@mssys.com>
Re: Unmatched Single Quote <kliquori@my-deja.com>
Re: unsolved: <STDIN> <schneider@xtewa.de>
Re: unsolved: <STDIN> <schneider@xtewa.de>
Re: What if $SIG{__DIE__} is occupied by other module? <bart.lateur@skynet.be>
Re: which linux for Perl 5.6? <dela@nospam.ukonline.co.uk>
Re: Your help please <taboo@comcen.com.au>
Re: Your help please <jochen@c-lab.de>
Re: Your help please <katie.foster@bt.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Dec 2000 12:16:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: -T & cgi security help with code!
Message-Id: <slrn92pn4d.rsu.abigail@tsathoggua.rlyeh.net>
On 04 Dec 2000 15:40:51 -0800, Randal L. Schwartz (merlyn@stonehenge.com) wrote in comp.lang.perl.misc <URL: news:<m1wvdfn4ak.fsf@halfdome.holdit.com>>:
++
++ And you appeared NOT to check the return value of getpwnam, which
++ would have made $dir undef, which would have overwritten /.qmail,
++ which would have permitted anyone to create a command mail such
++ that when mail was sent to root, would have root's permission!
Except of course that qmail doesn't want you to shoot yourself
in the foot and doesn't treat root as a normal user to begin with! ;-)
Abigail
------------------------------
Date: Tue, 5 Dec 2000 14:11:12 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Re: adduser
Message-Id: <90iovn$9ia$1@newstoo.ericsson.se>
Hi,
I was wondering, how do you random the characters ?
"Josef Moellers" <josef.moellers@fujitsu-siemens.com> wrote in message
news:3A2610A1.3CCBD7D2@fujitsu-siemens.com...
Per- Fredrik Pollnow wrote:
>
> Aaa sorry, FreeBSD. I have done the adduser thing..I find it on
> www.perlguru.com <http://www.perlguru.com> .) The only thing I need help
> with fore the moment is how to random a password :)
How about using the rand function to generate random numbers and use
those to select random characters from a-zA-Z0-9 and assorted characters
...
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Tue, 05 Dec 2000 14:34:20 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: adduser
Message-Id: <3A2CEEDC.D0675F7A@fujitsu-siemens.com>
Per- Fredrik Pollnow wrote:
> =
> Hi,
> =
> I was wondering, how do you random the characters ?
You fill a string with those characters you want to choose from:
@a =3D ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '_');
Then you use the rand function several times to select random
characters:
$passwd =3D "";
for ($i =3D 0; $i < 10; $i++)
{
$r =3D rand(63);
$r =3D int($r);
$passwd .=3D $a[$r];
}
print "$passwd\n";
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: 5 Dec 2000 11:20:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: array of unique random numbers
Message-Id: <slrn92pjs7.rsu.abigail@tsathoggua.rlyeh.net>
On 04 Dec 2000 16:41:29 -0500, Joe Schaefer (joe+usenet@sunstarsys.com) wrote in comp.lang.perl.misc <URL: news:<m3aeaboody.fsf@mumonkan.sunstarsys.com>>:
++ abigail@foad.org (Abigail) writes:
++
++ > ++ I wrote:
++ > ++ > If you have a large set of numbers to choose from, for instance, the
++ > ++ > reals between 0 and 1:
++ > ++ >
++ > ++ > while (keys %hash < 50) {$hash {+rand} = 1}
++ > ++ > @array = keys %hash;
++ > ++
++ > ++ I think you left out
++ > ++
++ > ++ shuffle(@array);
++ > ++
++ > ++ keys %hash is curiously ordered list of random elements, and not a
++ > ++ (random) list of random elements.
++ >
++ >
++ > And since the OP asked for an array of random numbers without duplicates
++ > what's wrong with keys %hash?
++ >
++
++ It's an ordered list. The order depends on the elements in the list,
++ which means if you're using the elements of keys %hash sequentially,
++ more info is available than simply "the next element won't be amongst
++ the previous ones". Ordering reduces the randomness of the numbers
++ in the remainder of the list, just as if you had done
++
++ @array = sort keys %hash;
++
++ Since OP didn't ask for an ordered list of random numbers, I
++ assumed that s/he needed an unordered list.
This is what the OP asked:
>> I need to produce an array of random numbers, but each of them needs
>> to be unique ie. if I have an array of 50 values, none can be replicated.
which is a 'list of random elements'. The fact there's some order in it
doesn't matter; there was no requirement to have a random order. If you
want a random order, fine, shuffle. But it's not a wrong answer if you
don't.
Abigail
------------------------------
Date: 05 Dec 2000 07:29:40 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: array of unique random numbers
Message-Id: <m31yvnnj9n.fsf@mumonkan.sunstarsys.com>
abigail@foad.org (Abigail) writes:
> This is what the OP asked:
> >> I need to produce an array of random numbers, but each of them needs
> >> to be unique ie. if I have an array of 50 values, none can be replicated.
>
> which is a 'list of random elements'. The fact there's some order in it
> doesn't matter; there was no requirement to have a random order. If you
> want a random order, fine, shuffle. But it's not a wrong answer if you
> don't.
s/50/2/:
I need to produce an array of 2 random numbers, but each of them
needs to be unique ie. if I have an array of 2 values, none can
be replicated.
Assume that the random numbers are to be selected from the
integers (1,2). A "keys %hash" implementation produces the
list (1,2) (or (2,1) depending on how hashes are implemented
on your box) with 100% certainty. With the shuffle added
in (or some other means that were mentioned by other
respondents- the shuffle is not necessary if you create
the list while the numbers are generated), you'll get the
other one roughly 50% of the time.
keys %hash reduces the randomness of the numbers in %hash.
Mathematically, you cannot discuss how random something is
until you have described the entire "process". Just because
your numbers were "randomly generated" does not mean you are
guaranteed that the ultimate list contains "random elements".
--
Joe Schaefer
------------------------------
Date: 5 Dec 2000 13:16:45 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: array of unique random numbers
Message-Id: <90iprt$1ni$1@lublin.zrz.tu-berlin.de>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote in comp.lang.perl.misc:
>abigail@foad.org (Abigail) writes:
>
>> This is what the OP asked:
>> >> I need to produce an array of random numbers, but each of them needs
>> >> to be unique ie. if I have an array of 50 values, none can be replicated.
>>
>> which is a 'list of random elements'. The fact there's some order in it
>> doesn't matter; there was no requirement to have a random order. If you
>> want a random order, fine, shuffle. But it's not a wrong answer if you
>> don't.
>
>s/50/2/:
>
>I need to produce an array of 2 random numbers, but each of them
>needs to be unique ie. if I have an array of 2 values, none can
>be replicated.
>
>Assume that the random numbers are to be selected from the
>integers (1,2). A "keys %hash" implementation produces the
>list (1,2) (or (2,1) depending on how hashes are implemented
>on your box) with 100% certainty. With the shuffle added
>in (or some other means that were mentioned by other
>respondents- the shuffle is not necessary if you create
>the list while the numbers are generated), you'll get the
>other one roughly 50% of the time.
Re-reading the original post, I get the impression the original
poster isn't interested in the ordering in which the numbers
appear, he wants a set of so many random numbers. So, as far
as the OP is concerned, the question is probably moot.
Anno
------------------------------
Date: Tue, 5 Dec 2000 21:29:01 +0800
From: "John" <john@imining.com.tw>
Subject: DBI insert problem
Message-Id: <90iqs4$ipc@netnews.hinet.net>
Hi all:
I am using DBI to write a database program.
I have prepared an insert SQL command.
The target database is MS Access.
Database driver is DBD::ODBC.
One field of the table is of the type 'memo'.
When I insert a long string(about 300 characters) into this field, I get an
error.
But when I use do to insert the same data, I succeed.
Everything is ok with short strings.
WHY?
Thanks in advance.
John Hsieh
john@imining.com.tw
------------------------------
Date: Tue, 05 Dec 2000 11:00:48 GMT
From: eastking@my-deja.com
Subject: fetch by array
Message-Id: <90ihsv$q3q$1@nnrp1.deja.com>
Hi,every one here.
I am using perl to fetch data from Oracle. I have to fetch them on by
one.
I used to fecth data by array ( about 200 for each fetch) using Pro*c.
It is much faster .
so I want to know is it possible fetch data by array in perl.
thanks in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 04:11:11 -0800
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: Help with /\d+\s*(S+)/ Please
Message-Id: <051220000411114803%lincmad001@telecom-digest.zzn.com>
In article <3A2AE9BE.FF4FAB93@home.com>, Ned <ned911@home.com> wrote:
> Data: Name|Date|VacDay|SicDay|Comments
>
> Joe Smith|10-21-2000 09:35|1|0|Vacation
> Jane Smith|11-15-2000 10:35|0|1|Dr Appointment
>
> > >and the line /\d+\s*(S+)/ is causing the Nov data to be sorted
> > >correctly (I'm using a descending sort)
> >
> > Got the code that does the sorting?
>
> @idx = ();
> for (@file) {
> ($item) = /\d+\s*(\S+)/;
> push @idx, uc($item);
> }
> @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];
Try something like this:
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#! perl -w
use strict;
my @file;
my %idx;
sub parsedate {
my $line = shift;
my ($name, $datestring) = split m(\|), $line, 3;
my ($month, $day, $year, $hour, $min) =
unpack "a2xa2xa4xa2xa2", $datestring;
return "$year$month$day$hour$min";
# or just "$year$month$day" if you don't care about the time
}
sub decliningdate {
$idx{$b} <=> $idx{$a}
or
$a cmp $b; # resolve cases with identical date
}
# ...(whatever you do to fill in "@file")...
%idx = map { $_, &parsedate($_) } @file;
@file = sort decliningdate @file;
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
If your system chokes on numbers like 200011151035 for the <=>
operator, you can either trim it to 20001115 or use the cmp operator
instead.
This code relies on your date values being expressed exactly as
mm-dd-yyyy hh:mm -- for example, "01-03-2001 09:02" rather than
something like "1-3-2001 9:02" or any other variation.
Of greater value in the long run, though, is to look at your own code
in a little bit greater detail. For instance:
@idx = ();
for (@file) {
($item) = /\d+\s*(\S+)/;
push @idx, uc($item);
}
for (0..$#file) {
print "$idx[$_]\t$file[$_]\n"; # look at what you're about to sort
}
# @file = @file [sort{$idx[$b] cmp $idx[$a]}0..$#idx];
My code at the top, by the way, is a fairly straightforward application
of the ideas in the entry for "sort" in the Camel book. Specifically,
"to sort a list value by some associated value, use a hash lookup in
the sort routine." I could have converted the date to the Unix format
of seconds since an arbitrary start date, but if you're only sorting --
not doing something like date A minus date B -- there's no need; just
manipulate the date into a format that sorts directly.
Also, as an aside, the other comments in this thread are entirely
valid: you didn't provide the information requested as to what your
input was, what you were doing with it, what you expected the output to
be, and what the output actually was. The bandwidth to post an article
that's 5K or 10K instead of 2K is much easier to come by than the time
of people frustrated at trying to guess what you're asking.
Now see if you can understand how exactly my sample code and Tad's
achieve your goal (or how exactly they don't).
------------------------------
Date: 5 Dec 2000 11:21:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help with getting an array
Message-Id: <90ij4i$1hk$1@lublin.zrz.tu-berlin.de>
<debcod@my-deja.com> wrote in comp.lang.perl.misc:
>I haven't worked with Perl for several years, and
>was asked to do something that should be rather
>simple, but I can't remember how. I need to read
>through log files and pull out two different
>lines, then print into a comma-delimited list.
>
>I can get the script to read through all the
>right files and pull out the correct lines, but
>can only get it to print the last record. I know
>I have to get each of the lines I want into an
>array, but I'm running into a blank wall on
Why do you think you need an array? I don't see how that would help.
>how....I know this is really simple....be kind,
>don't tell me how absolutely stupid I am....just
>take pity on me!
>=====================
>Here's a snippet:
>=====================
>
>my ($cart, $cartlabel, $srvr, $dlt, $drvlabel,
>$jobname);
>
> foreach $file (<BEX*.txt>) {
>
> open(FILES, "<$file");
You are not checking the result of open(). You will want to skip
a loop when a file can't be opened ( ...or next;). But that is
unlikely to be the reason for your problem.
> <FILES>;
Here you are reading and discarding the first line in $file. I don't
think that's what you want.
[rest of code snipped (it looked good to me)]
Otherwise, your code is fine, and after dropping the spurious <FILES>
it prints three items after each file. No need to use an array if
you have a fixed number of lines to catch.
Anno
------------------------------
Date: Tue, 5 Dec 2000 11:38:35 +0000
From: Dominic Hibbs <mtx064@coventry.ac.uk>
Subject: Re: how to do Https:// through perl ?
Message-Id: <Pine.OSF.3.91.1001205112530.13286D-100000@leofric>
On Sun, 3 Dec 2000, GOGAR wrote:
> I've been trying to downloading pages from the net and sending some forms
> forms using perl, but i can't quite figure out how to do Secure connections
> stuff.. anybody got a clue?
Just working on this now. I can get pages but as yet not send forms.
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $netloc = "foo.bar.net:80";
my $realm = "DNACS"; # Case sensitive - we found this from Netscape's
# login dialog box
my $uname = "d.hibbs";
my $pass = "D0m1n1c";
$ua->credentials($netloc,$realm,$uname,$pass);
my $url = "http://foo.bar.net/dnacs/docs/page.shtml";
my $request = HTTP::Request->new('GET',$url);
my $response = $ua->request($request,"filename");
I am very new to perl so if it doesn't work I apologise.
-----------------------------------------------------
Dominic Hibbs (Senior Lecturer)
School of Maths and Information Sciences
Coventry University
Priory Street
Coventry
CV1 5FB
02476 631313 Ext 7063
-----------------------------------------------------
------------------------------
Date: Tue, 05 Dec 2000 13:46:58 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: kill and security (suid)
Message-Id: <3A2CF53C.C273776C@home.com>
Chris Fedde wrote:
>
> In article <87k89ftryb.fsf@nujoma.perrins>,
> Andrew J. Perrin <aperrin@demog.berkeley.edu> wrote:
> >
> > kill 'TERM', $_ and print "Killed $_\n";
kill 'TERM', $_ or die "Kill '$_' failed: $!\n";
I have no idea what the problem is but this may give more info.
You should be able to find more detail about the error message in
kill(2).
> >I get no output. However, if I just print it:
> >
> >print "Killing $_\n";
> >kill 'TERM', $_;
> >
> >it does print, and I manually issue a /bin/kill -TERM <pid>
> >immediately thereafter it works fine.
> >
>
> Use one of the following:
>
> kill TERM, $_; # no quotes
That will make no difference, unless he is using strict 'subs' in which
case the program won't compile. perlfunc specifically says to use
quotes which includes
kill TERM => $_;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 5 Dec 2000 13:31:30 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: learning perl, this does not work ... why?
Message-Id: <90iqni$1p2$1@lublin.zrz.tu-berlin.de>
Helgi Briem <helgi@NOSPAMdecode.is> wrote in comp.lang.perl.misc:
>On Sun, 03 Dec 2000 04:23:32 +0600, "Jerry F. Davis"
><jfdecd@execpc.com> wrote:
>
>>Hey all:
>>
>>I am just learning perl. I have perl 5.6.0 for i686-linux
>>
>You posted this three times, a good way to
>ensure nobody replies. But I'm a nice guy.
>
>>I put in the following script (from Beginning perl by Simon Cozens)
>>expecting the $1 .. $5 variables to print something.
>>I get the first print line, "The text matches ...", but do not get
>>anything for $1 as I expected.
>>
>>why?
>>
>You need to enclose $pattern in
>parentheses in order to capture $1
>thus: >if (/($pattern)/) {
>
>You also have only one pattern so
>$2-$5 will always be undefined.
Not if the pattern in $pattern contains capturing parantheses.
Anno
------------------------------
Date: 5 Dec 2000 12:48:45 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Lost in a sea of obfuscation...
Message-Id: <976019987.1409@itz.pp.sci.fi>
In article <90hb9i$20tm$1@newssvr06-en0.news.prodigy.com>, Ryan Joseph wrote:
>
>Here is my dillema - I really want to write a JAPH, yet I have no clue how
>to go about this. Is there any stratigies, tips, techniques, or magic tricks
print "Just another Perl hacker,\n";
There. That's a start. Then you wait until you think of some way to
make it more difficult, and try to cram it into one line of Perl. For
example, the following was inspired by watching the "blitspin" module
for xscreensaver:
$;=s//,rekcah lreP rehtona tsuJ\n/;$;+=$;while print,s/(.{$;})(.{1,$;})/$2$1/g
Tips on making the code shorter and less readable are best found by
examining JAPHs and other obfuscated code written by other people.
Reading some of the more obscure parts of the Perl documentation can
also be useful, often in more normal circumstances as well.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 05 Dec 2000 13:53:00 +0100
From: David Hiskiyahu <David.Hiskiyahu@alcatel.be>
To: Darold Anderson <deandeson2@mmm.com>
Subject: Re: Question: How to Return script name from within script.
Message-Id: <3A2CE52C.51E9DF89@alcatel.be>
In case of a http/CGI Perl script, you might as well use
...
$log = "error message generated from $ENV{'SCRIPT_NAME'}\n";
...
Darold Anderson wrote:
>
> I am writing some scripts that have a sub in them that is generic across
> about a dozen or so other scripts. I want to generate some error messages
> from within the sub and would like to include the name of the script that
> generated the error so that I can see which one of the dozen actually
> created it.
>
> I know I can send it as an input parameter like this:
> /usr/local/bin/perl/example1.plx <P1> <P2> example1.plx
>
> but I would rather have it done within the module like this:
> sub foo {
> if (...) {
> ...;
> }else {
> $log = "generic error message generated from $filename";
> }
> }
>
> Where $filename returns the name of the script that is currently running
> (example1.plx).
>
> Any and all ideas are welcome!
>
> Thank you,
> Darold Anderson
--
*** David Hiskiyahu, Alcatel SRD, 1 Fr.Wellesplein, Antwerp ***
*** Phone/Fax: +32 3 240 7965/9820, private +32 3 290 0912 ***
Quote of the day:
"The doctors X-rayed my head and found nothing."
- Dizzy Dean, St Louis Cardinals Pitcher
------------------------------
Date: 5 Dec 2000 12:24:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: references, hashes & arrays
Message-Id: <976016931.22359@itz.pp.sci.fi>
In article <90ihun$gi3$2@bob.news.rcn.net>, Eric Bohlman wrote:
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>
>> $unit{'$in{'unit'}'}
>
>> means that you want to access the element of hash %unit which has the
>> key - "a literal dollar sign, an i, an n, a literal opening curly,
>> etc." Try getting rid of those outermost 's like so:
>
>> $unit{$in{'unit'}}
>
>Right solution, but wrong explanation. Single quotes inside double quotes
>are treated literally; they don't suspend interpolation. In this case,
>the hash key was a single quote followed by an a, a k, an r, an n, and
>another single quote. The literal single quotes in the key were
>preventing it from matching.
I'd say you're both wrong. The original expression contains, like the
error message in the original post said, a syntax error that prevents
any meaningful hash key from being computed. The string of code would
get broken into tokens roughly as follows:
$ dollar sign
unit identifier
{ opening brace
'$in{' single quoted string
unit identifier
Now this is where one would expect the parsing to fail -- and in fact
if you remove the next three characters, it will do so. But it seems
that the parser, seeing the next single quote after "unit", assumes
it's Perl 4 -style package delimiter, equivalent to "::" in modern
Perls, and the complains about the closing brace where it expected
another identifier.
Now, if it had been $unit{"'$in{'unit'}'"} vs. $unit{"$in{'unit'}"},
_then_ you (Eric Bohlman) would've been right. But it wasn't.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 05 Dec 2000 14:19:01 +0100
From: Hermann FASS <hermann_fass@hotmail.com>
To: rereidy@my-deja.com
Subject: Re: sending attachments with email
Message-Id: <3A2CEB44.CC7B27FC@hotmail.com>
rereidy@my-deja.com wrote:
> I need to send an email and attach a file to it from UNIX. What Perl
> module is the easiest to use to accomplish this task?
Not economic looking at the required coding- and learning-efforts, but
for completeness:
You could of course use Mime::Base64 to encode the binary parts of a
multipart-message.
Print/pipe the text-part directly and the Base64-encoded parts to
sendmail.
O'Reilly's "Programming Internet Email" was good help.
I tried it an it worked, but it was a bit reinventing the wheel (?)
Hermann
------------------------------
Date: Tue, 05 Dec 2000 14:19:25 +0100
From: Hermann FASS <hermann_fass@hotmail.com>
To: rereidy@my-deja.com
Subject: Re: sending attachments with email
Message-Id: <3A2CEB5D.2C8740B4@hotmail.com>
rereidy@my-deja.com wrote:
> I need to send an email and attach a file to it from UNIX. What Perl
> module is the easiest to use to accomplish this task?
Not economic looking at the required coding- and learning-efforts, but
for completeness:
You could of course use Mime::Base64 to encode the binary parts of a
multipart-message.
Print/pipe the text-part directly and the Base64-encoded parts to
sendmail.
O'Reilly's "Programming Internet Email" was good help.
I tried it an it worked, but it was a bit reinventing the wheel (?)
Hermann
------------------------------
Date: Tue, 05 Dec 2000 19:42:58 +0800
From: TomC <livia74@ctimail3.com>
Subject: Serial module
Message-Id: <3A2CD4C2.95831C9@ctimail3.com>
Hi all,
Can anyone know the function of the module Device::Serial and how to
use?
Any web site which will clearly explain of it?
Thanks
Brian
------------------------------
Date: Tue, 05 Dec 2000 13:37:33 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Sorting the result of a function
Message-Id: <3A2CE18D.AB183D98@mssys.com>
Tad McClellan wrote:
> It _is_ in the docs, but you have to look hard.
>
> It is, in fact, in the very part of the docs that talk about
> optional parenthesis for functions arg lists :-)
True, it is in the docs, I read this part in the Camel book. :-)
What I was trying to say was that IMO 'sort +f()' demonstrates the
practical use of the unary plus in a more "realistic" or "natural"
situation than
> print +(1+2)+4; # Prints 7.
or 'rand +(10) * 20; # rand (10 * 20).
But that's just my opinion. :-)
Playing around with f() and sort() I found another nice "trap":
perl -Mstrict -we "sub f{ (3,2,1) } print sort f"
Where do I have to look harder this time?!
Cheers
Wolfgang
------------------------------
Date: Tue, 05 Dec 2000 13:51:17 GMT
From: kliquori <kliquori@my-deja.com>
Subject: Re: Unmatched Single Quote
Message-Id: <90irsj$165$1@nnrp1.deja.com>
I tried several suggestions here but only got this to work:
my $newissue = $dbh->quote("$issue"); $dbh->do( "insert into NetworkOutage
(Issue) values ($newissue)") or die "Cannot do: " . $dbh->errstr();
I started looking at bind_param() but it seemed pretty complicated. I need to
go back to it I just didn't have the luxury of time on this current project.
I appreciate all of the suggestions.
Thanks...Kevin
In article <975448075.10512@itz.pp.sci.fi>,
Ilmari Karonen <usenet11289@itz.pp.sci.fi> wrote:
> In article <9014uh$ci1$1@nnrp1.deja.com>, kliquori wrote:
> > I grab this field in the CGI script with:
> >
> > $issue = $q->param( "issuefld" );
> >
> > I try to insert it into the db in the same script with:
> >
> > $dbh->do( "insert into NetworkOutage (Issue) values ('$issue')")
> > or die "Cannot do: " .$dbh->errstr();
>
> [Whitespace added for readability.]
>
> my $issue = $dbh->quote( $q->param('issuefld') );
>
> $dbh->do("insert into NetworkOutage (Issue) values ($issue)")
> or die "Cannot do: " . $dbh->errstr();
>
> --
> Ilmari Karonen -- http://www.sci.fi/~iltzu/
> "Get real! This is a discussion group, not a helpdesk. You post
> something, we discuss its implications. If the discussion happens to
> answer a question you've asked, that's incidental." -- nobull in clpm
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 11:05:33 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: unsolved: <STDIN>
Message-Id: <90ii5r$qd3$1@nnrp1.deja.com>
> Instead use select to see if you can read, and then sysread to get
some
> data. Do this in a loop and you shouldn't have to block.
Hi,
hmh, I think it doesn't work the way it should - but why?
That's what I am doing:
#!perl -w
use strict;
my $input;
open( INPUT, "<&STDIN" );
select( INPUT ); $| = 1;
while(1)
{
print STDOUT $input . "\n" if( sysread ( INPUT, $input, 1 ) );
}
close ( INPUT );
and it still reads the input only after hitting enter...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 11:15:55 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: unsolved: <STDIN>
Message-Id: <90iip9$qpf$1@nnrp1.deja.com>
I just found the information.
Still, I don't feel bad about the posting ...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 12:02:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What if $SIG{__DIE__} is occupied by other module?
Message-Id: <mplp2ts0j4p0k1qqirf1jf0ube36v9m47l@4ax.com>
nobull@mail.com wrote:
>Bart Lateur <bart.lateur@skynet.be> writes:
>
>> >eval{} is the proper (stackable) way to catch exceptions.
>>
>> No: eval() is the CAUSE of the problem.
>
>No - mixing the two mechanisms of trapping __DIE__ exceptions is the
>cause of the problem. If you had used only eval{} you'd not have a
>problem.
>So do not set $SIG{__DIE__}, use eval {} and all will be well.
And what happened to TMTOWTDI? $SIG{__DIE__}, IMO, is a hook which
serves to customize the error message, or at leats, the printout of the
error message. eval BLOCK serves to *prevent* an error message, and
fatality. So why is a callback function to customize the error output
even called, when error messages aren't supposed to be printed? This is
nonsense.
$SIG{__DIE__}, as a hook, is layered on top op the standard behaviour.
Currently, eval BLOCK is layered *between* $the default behaviour, and
the $SIG{__DIE__} handler. It should really be, IMO, layered *on top* of
it, instead.
In a way, it'd even make sense if eval made use of the $SIG{__DIE__}
hook mechanism.
>It is all well documented, as is the $^S work-round so I see no urgent
>need to fix it even if the docs warn that one day it may be fixed.
BS. Now, there are at least two modules available from CPAN where
there's a fatal error if you had set $SIG{__DIE__}. So you claim this is
a bug in these modules? I think not.
Oh, wait, you say we should use
die @_ if $^@;
at the start of our $SIG{__DIE__} handler. Isn't that just a bit too
low level? Isn't that something the system should silently do or us,
automatically?
--
Bart.
------------------------------
Date: Tue, 05 Dec 2000 12:10:19 +0000
From: "Dela Lovecraft" <dela@nospam.ukonline.co.uk>
Subject: Re: which linux for Perl 5.6?
Message-Id: <OX4X5.388$Wi2.6871@news2-win.server.ntlworld.com>
> I want to choose a linux dist for my desktop, and want one with the
> current perl release. I see the stable debian only has up to 5.004...
Well, I am using Storm Linux 2000 which comes with Perl 5.004. But
I have downloaded and installed the Perl 5.6 packages from debian.org
unstable branch, and I have found no problems at all with it.
> So, which is the best linux dist for me so I ca play with the latest and
> greatest Perl?
Mandrake Linux comes with 5.6, and is a very good distro. You say you
are new to Linux as well...? Mandrake is a very good first one to use, and
helps a lot with configuration of hardware etc. Worth a look.
Dela Lovecraft
------------------------------
Date: 5 Dec 2000 23:21:04 +1100
From: "kiel stirling" <taboo@comcen.com.au>
Subject: Re: Your help please
Message-Id: <3a2cddb0$1@nexus.comcen.com.au>
"Katie Foster" <katie.foster@bt.com> wrote:
>I haven't been doing Perl very long, so I was hoping someone on here could
>help me, please.
>
>My group have upgraded from Perl 3 to Perl 5.05. Some of our scripts no
>longer work, I have fixed some of them, but have come accross a problem with
>one particular script.
>
>The script is called from another scripts which sets the frames up on the
>page. Two of the frames work fine, but one frame doesn't work. It
>produces the error message Premature end of script headers: /name of file.
>
>If you re-fresh the frame then it works and does not produce an error
>message.
>I have cheked the environment variables by printing them to the errorlog,
>When I do this the script works fine. If I just print a line saying Test
>into the errorlog then that also works.
>
>Anyone any ideas on why it isn't working or how to fix it??
>
>Thanks Katie
Post the script to this group for all to read
------------------------------
Date: Tue, 05 Dec 2000 13:34:10 +0100
From: Jochen Luig <jochen@c-lab.de>
Subject: Re: Your help please
Message-Id: <3A2CE0C2.89C66A43@c-lab.de>
Hi!
> The script is called from another scripts which sets the frames up on the
> page. Two of the frames work fine, but one frame doesn't work. It
> produces the error message Premature end of script headers: /name of file.
(...)
>
> Anyone any ideas on why it isn't working or how to fix it??
perldoc perldiag is your friend.
search for 'Server Error'.
Bye
Jochen
------------------------------
Date: Tue, 5 Dec 2000 13:09:29 -0000
From: "Katie Foster" <katie.foster@bt.com>
Subject: Re: Your help please
Message-Id: <90iphd$9ut$1@pheidippides.axion.bt.co.uk>
I have that fixed now, thanks anyway. But I am having a problem with
another script. It is called from from the web. The error message it
brings back is
Premature End of script
#!/usr/local/bin/perl -w
#
# Shows the system messages of the day. If the user has invoked this file
# via the featuresbar icon then the file is displayed if it exists. If it
# does not exist then a message tells the user that there are no messages.
# If the script has been called via index.html then the message is
displayed,
# on pressing continue index.cgi is called. If there is no message then
# index.cgi is called directly.
use lib qw(/WOOSH/cgi-bin);
use CGI qw(:cgi-lib);
require "util-lib.pl";
use strict;
MAIN:
{
Check user hasn't accessed page directly.
my $access = &CheckAccess();
if ( $access eq "false" )
{
exit;
}
my(%input) = ();
&ReadParse(\%input);
&ReadWooshEnv ("/WOOSH", *ENV);
my $WWW_PATH = "$ENV{'WOOSH_PROFILE_PATH'}";
my $rem_user = $ENV{'REMOTE_USER'};
my $MessageFile = "$WWW_PATH/admin/SystemMessages.txt";
my $option = "default_failure";
if (exists $input{'Option'})
{
$option = $input{'Option'};
}
if ($option ne "View")
{
if (-e $MessageFile)
{
print "Content-type: text/html", "\n\n";
print "<BODY>";
print "<HEAD>";
print "<TITLE>System Messages</TITLE>";
print "</HEAD>";
print "<CENTER>";
print "<H1>System Messages</H1>";
print "</CENTER>";
print "<FORM ACTION=\"/cgi-bin/index.cgi\"
METHOD=\"POST\">";
print "<BR>";
open(MESSAGE_FILE, "$MessageFile") || die ("Failed to open
$MessageFile $!");
while (<MESSAGE_FILE>)
{
print "$_<BR>";
}
print "<BR>";
print "<HR>";
print "<INPUT TYPE=\"submit\" VALUE=\"Continue\">";
print "</FORM>";
print "<INPUT TYPE=\"submit\" VALUE=\"Continue\">";
print "</FORM>";
print "</BODY>";
print "</HTML>";
}
else
{
print "Location: index.cgi", "\n\n";
}
}
if ($option eq "View")
{
if (-e $MessageFile)
{
print "Content-type: text/html", "\n\n";
print "<BODY>";
print "<HEAD>";
print "<TITLE>System Messages</TITLE>";
print "</HEAD>";
print "<CENTER>";
print "<H1>System Messages</H1>";
print "</CENTER>";
print "<BR>";
open(MESSAGE_FILE, "$MessageFile") || die ("Failed to open
$MessageFile $!");
while (<MESSAGE_FILE>)
{
print "$_<BR>";
}
print "<BR>";
print "<HR>";
print "</BODY>";
print "<HR>";
print "</BODY>";
print "</HTML>";
}
else
{
print "Content-type: text/html", "\n\n";
print "<BR>";
print "<B>No current System Messages.</B>\n";
}
}
}
exit;
"Katie Foster" <katie.foster@bt.com> wrote in message
news:90if3b$61i$1@pheidippides.axion.bt.co.uk...> I haven't been doing Perl
very long, so I was hoping someone on here could
> help me, please.
>
> My group have upgraded from Perl 3 to Perl 5.05. Some of our scripts no
> longer work, I have fixed some of them, but have come accross a problem
with
> one particular script.
>
> The script is called from another scripts which sets the frames up on the
> page. Two of the frames work fine, but one frame doesn't work. It
> produces the error message Premature end of script headers: /name of file.
>
> If you re-fresh the frame then it works and does not produce an error
> message.
> I have cheked the environment variables by printing them to the errorlog,
> When I do this the script works fine. If I just print a line saying Test
> into the errorlog then that also works.
>
> Anyone any ideas on why it isn't working or how to fix it??
>
> Thanks Katie
>
>
------------------------------
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 V9 Issue 5035
**************************************