[24948] in Perl-Users-Digest
Perl-Users Digest, Issue: 7198 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 1 06:07:10 2004
Date: Fri, 1 Oct 2004 03:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 1 Oct 2004 Volume: 10 Number: 7198
Today's topics:
Re: "su -" in CGI script ? <robert.nilsson@monet.no>
Re: "su -" in CGI script ? <robert.nilsson@monet.no>
Re: "su -" in CGI script ? chris-usenet@roaima.co.uk
Re: $SIG{CHLD} and system (Heinrich Mislik)
ANNOUNCE: WWW::Webrobot 0.51 <webrobot@abas.de>
Re: Help with my brute force method (Charles DeRykus)
Re: How to merge .wav files <jarsonk@nospam.com>
Re: How to merge .wav files <tassilo.von.parseval@rwth-aachen.de>
Re: How to merge .wav files <spamtrap@dot-app.org>
Re: How to merge .wav files (Anno Siegel)
Re: How to merge .wav files (kevin)
Re: how to put constaints on coefficients obtained from ctcgag@hotmail.com
m//i behaves strange : variable does not match itself <pilsl@goldfisch.at>
Re: match a long string in Regex.. <end@dream.life>
Re: modeling an object many to many relationship with a ctcgag@hotmail.com
Re: Odd sort() problem (Douglas Wilson)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
SOAP Http Client (Paul Masquelier)
Re: sprintf problem (Tony Skelding)
Re: Symbolic algebra <see@sig.invalid>
Re: tr problem <eric-amick@comcast.net>
Re: tr problem <thepoet_nospam@arcor.de>
Re: unicode: is decode-process-encode a "good" aproach? <pilsl@goldfisch.at>
Re: Who's responsible for this ? <tassilo.von.parseval@rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 1 Oct 2004 08:49:56 +0200
From: "Robert Nilsson" <robert.nilsson@monet.no>
Subject: Re: "su -" in CGI script ?
Message-Id: <cjiumk$6ep$1@services.kq.no>
<chris-usenet@roaima.co.uk> skrev i melding
news:sret22-fmj.ln1@moldev.cmagroup.co.uk...
> Robert Nilsson <robert.nilsson@monet.no> wrote:
> > I'm trying to execute a specific command from a CGI script written in
PERL.
> > I have to be a special user so I've tried to use "su -" but it doesn't
work.
> > The CGI script is running as the user apache on the server, right? Is
that
> > the problem? Is there any other way to execute something with "system"
as
> > someone else within perl?
>
> This is an OS question (UNIX) not a perl one. "su" requires a password. If
> you're running a CGI script there's no terminal from which it can get
> the password. Read "man su" for details.
>
> I don't understand what you mean by << executing something with "system"
>>,
> though.
>
> Chris
.... the command "system" in PERL
------------------------------
Date: Fri, 1 Oct 2004 08:58:23 +0200
From: "Robert Nilsson" <robert.nilsson@monet.no>
Subject: Re: "su -" in CGI script ?
Message-Id: <cjiv6g$98k$1@services.kq.no>
"Gregory Toomey" <nospam@bigpond.com> skrev i melding
news:2s2g6mF1fgj9iU1@uni-berlin.de...
> Robert Nilsson wrote:
>
> > Hello
> >
> > I'm trying to execute a specific command from a CGI script written in
> > PERL. I have to be a special user so I've tried to use "su -" but it
> > doesn't work. The CGI script is running as the user apache on the
server,
> > right?
> We dont know, you're telling the story.
>
> > Is that the problem? Is there any other way to execute something
> > with "system" as someone else within perl?
> >
> >
> > Robert
>
> Try a setuid wrapper, to run as the user you want.
> http://httpd.apache.org/docs/suexec.html
>
> gtoomey
Thank you! This is what I was looking for.
Problem solved.
/ Robert
------------------------------
Date: Fri, 1 Oct 2004 10:07:48 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: "su -" in CGI script ?
Message-Id: <4cjv22-b37.ln1@moldev.cmagroup.co.uk>
>> I don't understand what you mean by << executing something with "system"
>> Chris
Robert Nilsson <robert.nilsson@monet.no> wrote:
> .... the command "system" in PERL
Doh; I was still thinking in UNIX terms. Glad to see you've got a solution
from another poster, though
Chris
------------------------------
Date: 01 Oct 2004 10:03:10 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: $SIG{CHLD} and system
Message-Id: <415d2b5e$0$31502$3b214f66@usenet.univie.ac.at>
In article <415c5847$0$8106$9b4e6d93@newsread4.arcor-online.net>, thepoet_nospam@arcor.de says...
>
>
>Heinrich Mislik wrote:
>> perl -e '$SIG{CHLD} = "IGNORE";system("date") and die'
>>
>> gives me
>>
>> Thu Sep 30 14:34:22 MSZ 2004
>> Died at -e line 1.
>>
>> I can understand, why this happens. But is it documented? Shouldn't system
>> set up it's own signalhandlers? The function system in C does so. Does this
> > mean, that perl does not call this function?
>>
>> Any thoughts
>
>Mostly one thought: read "perldoc -f system". It forks a child
>and, in cases like yours when there's no meta chars in
>the argument string, calls execvp. No system() call invoked.
Right. But even with this its the same:
perl -e '$SIG{CHLD} = "IGNORE";system("date 2>/dev/null") and die'
Fri Oct 1 11:43:48 MSZ 2004
Died at -e line 1.
>Apart from that, I can't reproduce this behaviour
>(just tested 5.6.1 and 5.8.[03] on Linux and Win32).
>%SIG isn't changed by the call of system("date").
Just to clarify: my point is, that the returncode of system is changed by setting $SIG{CHLD} = "IGNORE".
>What version and OS are you on?
I tried
This is perl, v5.8.4 built for aix
This is perl, v5.6.1 built for i386-freebsd
This is perl, v5.8.2 built for cygwin-thread-multi-64int
cygwin is a bit different with the last examle (with the 2>/dev/null):
sh gets into an enless loop. This seems to be a problem with cygwin's
C-function system.
Cheers
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
------------------------------
Date: Fri, 1 Oct 2004 08:54:33 GMT
From: Stefan Trcek <webrobot@abas.de>
Subject: ANNOUNCE: WWW::Webrobot 0.51
Message-Id: <I4wFLp.qMz@zorch.sf-bay.org>
Webrobot 0.51 is now available on CPAN. For Changes to previous
versions see the Changes file
http://search.cpan.org/dist/webrobot/Changes
Webrobot http://search.cpan.org/dist/webrobot/ is a data driven http
client heavily based on LWP. The client action specification format
ist XML. Though the module is pure Perl it uses some modules that are
not. It can be used
* for automating http requests
* for a kind of web based unit tests
* for stress tests of web servers (limited).
For more information see the README file in the distribution
http://search.cpan.org/dist/webrobot/lib/WWW/Webrobot/pod/README.pod
and the support page http://webrobot.abas.de containing screenshots
and tutorials.
The support page also contains instructions how to write test plans
with Mozilla by just visiting the desired pages.
Stefan
------------------------------
Date: Thu, 30 Sep 2004 22:07:54 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help with my brute force method
Message-Id: <I4vK56.J0@news.boeing.com>
In article <20040927125826.247$yO@newsreader.com>, <ctcgag@hotmail.com> wrote:
>> that takes care of it most of the time....
>> [snipped]
>
>
>However, the automatic closing does not die or warn upon failure.
>If you open an actual file for reading, this probably isn't a problem,
>but if you open a pipe command, it can be. Since one of the things I like
>about perl the ready ability to change file opens into pipe opens, I am
>careful to avoid situations where doing just that would create hard to find
>bugs.
>
Thanks for raising the issue. After suffering a severe exit wound
once when a partition filled, I have great affinity for T.Christ's
Cookbook advise:
"Those implicit closes are for convenience, not stability,
because they don't tell you whether the system call
succeeded or failed. Not all closes succeed. Even a
close on a read-only file can fail. For instance, you
could lose access to the device because of a network
outage. It's even more important to check the close if
the file was opened for writing. Otherwise you wouldn't
notice if the disk filled up."
--
Charles DeRykus
------------------------------
Date: Thu, 30 Sep 2004 22:01:15 -0400
From: "Jarson" <jarsonk@nospam.com>
Subject: Re: How to merge .wav files
Message-Id: <NT27d.20806$MD5.1134122@news20.bellglobal.com>
>"Fred Toewe" <ftoewe@austin.rr.com> wrote in message
>news:v4%6d.1748$YT3.810@fe2.texas.rr.com...
[snip]
>
> Have a look at http://www.xav.com/perl/site/lib/Win32/Sound.html
> It might get you close enuff to where you can code it.
>
Nothing really applicable in that library. It is for playing sound in
Windows systems. I don't wish to actually play any sound on my Unix server;
the sound will be served to the clients. There are also some
Audio::SoundFile libraries on CPAN for doing the same on unix, but I would
hope that a simple merge would not require such a complex library.
------------------------------
Date: Fri, 1 Oct 2004 08:48:01 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: How to merge .wav files
Message-Id: <2s4ct4F1h97baU1@uni-berlin.de>
Also sprach Jarson:
> I'm building a web-based message alert system in Perl (CGI) using voice TTS.
> Each web client will get a custom voice message that will actually consist
> of selected .wav files merged together to appear as one. My problem, is
> that I don't know how to handle .wav files to merge them properly under
> Perl.
Merging two .wav files is relatively easy. All you have to do is going
sample-wise through both of them in parallel, add the two samples (a
sample is just a signed integer) and write the new value to another
file. You can do the reading with Audio::WAV::Read::read() and writing
with Audio::WAV::Write::write().
Some things to watch for: You have to truncate values when they would go
beyond the maximum or minimum range of the bitrate. For 16 bits the
range is +/- 2**15 - 1. Otherwise they wrap around. Then the two .wav
files should have the same format. If file one is stereo and the second
one mono you always read two samples of the first file and one of the
second and add the second value to the first two values. When they
differ in bitrate you have to convert the samples of the file with the
lower bitrate accordingly (a 8 bit sampling-rate means that you have to
distribute the values in the range (-128 .. 127) to values in the range of
(-2**15 .. 2**15 - 1). Most of the time this distribution happens
evenly. Different sample frequency means that you skip certain samples
in the file with the higher frequency.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 01 Oct 2004 03:38:39 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to merge .wav files
Message-Id: <jv2dnWG4jYgdlMDcRVn-sA@adelphia.com>
Tassilo v. Parseval wrote:
> Some things to watch for: You have to truncate values when they would go
> beyond the maximum or minimum range
Ouch, just reading this makes my ears hurt! Truncation results is sound
waves that are squared off at the top and/or bottom. It's commonly known
as "clipping", and it sounds horrible.
Don't truncate when you're doing the addition. Do the math with 32, 64,
or even 96-bit ints internally to allow for plenty of headroom, and
normalize the output to the desired bit width only on output.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 1 Oct 2004 09:20:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to merge .wav files
Message-Id: <cjj7gq$pcd$1@mamenchi.zrz.TU-Berlin.DE>
Sherm Pendley <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> Tassilo v. Parseval wrote:
>
> > Some things to watch for: You have to truncate values when they would go
> > beyond the maximum or minimum range
>
> Ouch, just reading this makes my ears hurt! Truncation results is sound
> waves that are squared off at the top and/or bottom. It's commonly known
> as "clipping", and it sounds horrible.
>
> Don't truncate when you're doing the addition. Do the math with 32, 64,
> or even 96-bit ints internally to allow for plenty of headroom, and
> normalize the output to the desired bit width only on output.
I'm no audio buff, but using more than 32 bits to calculate 16 bit
quantities sounds excessive.
Alternatively to truncation or normalization, calculating a (possibly
weighted) average looks plausible too.
Anno
------------------------------
Date: 1 Oct 2004 02:25:58 -0700
From: kevinc@cinesite.co.uk (kevin)
Subject: Re: How to merge .wav files
Message-Id: <798c3a4c.0410010125.2be74a10@posting.google.com>
"Jarson" <jarsonk@nospam.com> wrote in message news:<xuY6d.20544$MD5.1043516@news20.bellglobal.com>...
> I'm building a web-based message alert system in Perl (CGI) using voice TTS.
> Each web client will get a custom voice message that will actually consist
> of selected .wav files merged together to appear as one. My problem, is
> that I don't know how to handle .wav files to merge them properly under
> Perl. Alternatively, if there is a way for a CGI program to send a stream
> of multiple separate .wav files, that would work to. Is there?
>
Jarson,
below is a perl script i wrote to add silence on the front of a wav file,
together with the notes i have on the wav file header. Unfortunately,
i can't remember where i got the wav file header docs from :(
the script ran on linux.
you should be able to merge wavs in a similar way.
HTH,
kevin
#!/usr/bin/perl -w
#
#
#
$|=1;
my $file=shift or usage();
my $offset=shift or usage();
my $new=shift or usage();
my $bytes=getBytes($file,$offset);
print "adding $bytes bytes\n";
writeWav($file,$bytes,$new);
print "done\n";
exit;
sub usage{
(my $prog=$0)=~ s{.*/}{};
print <<EOH;
Usage: $prog infile.wav offset outfile.wav
Add 'offset' frames of silence to the start of infile.wav
EOH
exit;
}
sub getBytes{
my ($file,$offset)=@_;
my $buffer;
open WAV,$file or die "cannot open $file\n";
read WAV,$buffer,4;
die "invalid wav file\n" unless $buffer eq 'RIFF';
read WAV,$buffer,8;
read WAV,$buffer,4;
die "invalid wav file\n" unless $buffer eq 'fmt ';
read WAV,$buffer,12;
read WAV,$buffer,4;
my $bytes=unpack("V",$buffer)/24;
#print "$bytes bytes per frame\n";
close WAV;
return $offset*$bytes;
}
sub writeWav{
my ($file,$bytes,$new)=@_;
open WAV,$file or die "cannot open $file\n";
open NEW,">$new" or die "cannot open $new\n";
#copy RIFF header
read WAV,$buffer,4;
print NEW $buffer;
read WAV,$buffer,4; #length
print NEW pack("V",$bytes+unpack("V",$buffer));
read WAV,$buffer,4;
print NEW $buffer;
#copy FORMAT chunk
read WAV,$buffer,24;
print NEW $buffer;
#copy DATA chunk adding in the extra silence
read WAV,$buffer,4;
print NEW $buffer;
read WAV,$buffer,4; #length ? bytes or samples ????
#print((unpack("V",$buffer)/4)." length\n");
#print((($bytes+unpack("V",$buffer))/4)." length\n");
print NEW pack("V",$bytes+unpack("V",$buffer));
#silence
print NEW pack("H","00") for 1 .. $bytes;
#sound
print NEW $buffer while read WAV,$buffer,2048;
close NEW;
close WAV;
}
#
# wav file
# unpack 4 bytes in V, two bytes in v
#
#RIFF
# 4 "RIFF"
# 4 length of package (binary, little-endian)
# 4 "WAVE"
#
#FORMAT
# 4 "fmt "
# 4 length
# 2
# 2 channels
# 4 sample rate
# 4 bytes/sec
# 2 bytes/sample
# 2 bits/sample
#
#DATA
# 4 "data"
# 4 length of data
# * data
------------------------------
Date: 30 Sep 2004 22:16:37 GMT
From: ctcgag@hotmail.com
Subject: Re: how to put constaints on coefficients obtained from regression.pm
Message-Id: <20040930181637.731$BQ@newsreader.com>
nsf470@yahoo.com (pj) wrote:
> Hi,
>
> I use regression package to do a multivariate linear regression fit to
> my data. Regression.pm generates coefficient values (thetas), but I
> want to make them always possitive. How do I put constraints (all
> coefficients are positive) when using regression package? any ideas?
I can't find a top-level module named Regression, so I don't know if it has
any specific capabilities to implement constraints. If not, you could just
iteratively remove any variables that come back with negative coefficients
and rerun the regression.
I'm not sure that this is gauranteed to lead to a globally optimal
solution, but if you are that particular about your statistical rigour, you
probably should probably be using a commercial regression application
anyway.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 01 Oct 2004 03:40:48 +0200
From: peter pilsl <pilsl@goldfisch.at>
Subject: m//i behaves strange : variable does not match itself
Message-Id: <415cb620@e-post.inode.at>
I use unicode and locales (de_AT.UTF-8) and - against warnings of
combing these - everything works fine (finally !!)
I can sort(), lc() and pattermatch but there is one very interesting
problem left with m//i : Characters with multibyte-representation only
match if the pattern is beheaded by something. I would not be suprised
if it never matches, but I am suprised that it only matches "sometimes"
and not even matches itself !!
example: (in german Ä ist the uppercase to ä)
Ä =~ m/Ä/i => no match !!
Ä =~ m/^Ä/i => match !!
Ä =~ m/^ä/i => match
bÄc =~ m/bä/i => match
bÄc =~ m/ä/i => no match
real source:
use locale;
$s="\x{e4}";
utf8::upgrade($s);
print $s=~/$s/i?"ok\n":"fail\n"
==> fail !!!
There is an easy workaround this, by calling lc() to the searchterm and
the pattern first and use m// without the i-flag then, but its an
interesting behaviour.
As I could see till now this phenomen does not depend on the special
locale used (de_AT.UTF-8, en_US, C ....) but occures as soon "use local"
is invoked.
peter
--
http://www2.goldfisch.at/know_list
http://leblogsportif.sportnation.at
------------------------------
Date: Fri, 01 Oct 2004 09:08:02 +0800
From: Alont <end@dream.life>
Subject: Re: match a long string in Regex..
Message-Id: <415cadc1.39965625@130.133.1.4>
"Paul Lalli" <mritty@gmail.com>Wrote at Wed, 29 Sep 2004 13:11:43 GMT:
>
>The four embedded newlines hear actually need to be doubly escaped.
>That is, the string should contain: \\\\n\\\\n rather than \\n\\n. This
>is because pattern matching passes through two sets of interpolation.
>First for double-quotish interpolation, then for regular expression
>interpolation.
>
>Additionally, because you are using double quotes to create $original,
>\( gets treated as an actual parentheses, which is then interpolated by
>the RegExp engine to mean "start capture". I would suggest changing to
>single-quotes here:
>my $original = q[javascript:if\(confirm\('(.*|\\n*) \\\\n\\\\nThis file
>was not retrieved by Teleport Pro, because it is addressed on a domain
>or path outside the boundaries set for its Starting Address\.
>\\\\n\\\\nDo you want to open it from the
>server\?'\)\)window\.location='];
>#all the above on one line
>
>One more thing - I don't think you're doing what you think you're doing
>with (.*|\n*). That will match any sequence of non-newlines, or any
>sequence of newlines. It will not match any sequence of characters
>which contains newlines. For that, stick with .* and add the /s switch
>to the pattern match.
>
>Paul Lalli
>
now it works, thank you :-)
--
Your fault as a Government is My failure as a Citizen.
------------------------------
Date: 01 Oct 2004 00:13:00 GMT
From: ctcgag@hotmail.com
Subject: Re: modeling an object many to many relationship with a transactional bridge table
Message-Id: <20040930201300.197$Nu@newsreader.com>
thomasoniii@gmail.com (Jim Thomason) wrote:
...
> The issue, as always, is that my join table contains additional
> information, start_date and end_date, for instance (when the student
> entered and exited that class), so I can't simply throw away that
> middle object.
>
> The solution I came up with is to subclass the Classroom class and
> wire it up to both the classes and the student_class_rlt table. Then
> the ->classes method returns these newly subclassed objects that are
> full fledged classrooms with some additional attributes (the user id,
> the start date, the end date).
I think that I would just make an "Enrollment" object which contains
a student object, a course object, plus a final grade field, the date
fields, etc.
>
> I really like this approach since it encapsulates everything nicely.
>
> my @classes = $student->classes;
my @courses = map $_->get_course, $student->get_enrollments();
>
> Thoughts?
Yes, I like "course" rather than "class" to refer to those things people
take in school, at least when one is engaged in OOP.
Alas, "course" is also overloaded, but not as badly as "class" is.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Use the cluster to cluster our clusters, and store the clusters in a
clustered table.
------------------------------
Date: 30 Sep 2004 15:26:55 -0700
From: dgwilson@gtemail.net (Douglas Wilson)
Subject: Re: Odd sort() problem
Message-Id: <a6d8fef9.0409301426.3657303c@posting.google.com>
Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnclnukk.kf2.tadmc@magna.augustmail.com>...
>
> I am unaware of this "named block" feature in Perl.
>
> Where exactly could I read up on it?
Perhaps he meant "labeled" block, which is indirectly mentioned
in perlsyn, but which the block being referred to most definitely
is not, since there is no ":" following the "lc".
------------------------------
Date: Fri, 01 Oct 2004 02:23:00 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <HtKdnYybztFJmMDcRVn-sQ@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: 1 Oct 2004 02:50:26 -0700
From: paulmasquelier@hotmail.com (Paul Masquelier)
Subject: SOAP Http Client
Message-Id: <c663070b.0410010150.6e6bdb4e@posting.google.com>
Hello,
I am trying to use the soaplite Http client to make a connection over
the internet.
I first tested it on the intranet company Lan : everything works fine.
Trying it in the big world however fails.
This is what I do :
- the http client code :
use SOAP::Lite;
$soaplite = SOAP::Lite->uri('urn:HelloWorld')->proxy('http://81.82.176.379/Soap_php/HelloWorld/helloserver1.php');
$soaplite->transport->proxy('http://81.82.176.379/Soap_php/HelloWorld/helloserver1.php');
$soaplite->outputxml(1);
$envelope = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><namesp14:message
xmlns:namesp14="urn:HelloWorld"/></SOAP-ENV:Body></SOAP-ENV:Envelope>';
my $response = $soaplite->transport->send_receive(
endpoint => $soaplite->endpoint,
action => '"urn:HelloWorld#Hello"',
envelope => $envelope,
encoding => $soaplite->serializer->encoding,
);
print $response;
1;
The code is nothing special, just the standard calls.
This works perfectly over the intranet lan.
The ip address I use is the temporary IP address the provider gave to
the destination pc. On both sides there is a direct connection with
the cable modem (no routers in between - just for test purposes of
course).
The ip address is obtained by the ipconfig command.
Reachability is tested with ping : works.
We used protocol analysers on both sides to check the tcp/ip traffic :
apparently only the first packet of the handshaking protocol is sent
(SYNC) several times; a reply on the first handshaking message to
establish a connection is never received. The receiver analyser on the
other side also never receives a packet from the sender.
I am completely blocked with this problem : if it works on intranet
why should it not work over the intranet if the destination is
reachable (ping) ??
Can anyone help me out here ?
Thanks for any help,
Paul
------------------------------
Date: 1 Oct 2004 03:05:14 -0700
From: tony@skelding.co.uk (Tony Skelding)
Subject: Re: sprintf problem
Message-Id: <a78026a1.0410010205.3786d738@posting.google.com>
"Billy N. Patton" <b-patton@ti.com> wrote in message news:<cjh82g$8oo$1@home.itg.ti.com>...
> My code:
> $lcname = 15;
> print sprintf("| %-m.ns |\n",$lcname,4,'CELL');
> print sprintf("| %m.ns |\n",$lcname,4,'CELL');
> print sprintf("| %mns |\n",$lcname,4,'CELL');
> print sprintf("| %s |\n",'CELL');
>
> The results:
> | %-m.ns |
> | %m.ns |
> | %mns |
> | CELL |
>
>
> I need the 'CELL' left justified, padded with spaces and using $lcname
> space.
>
> The camel book Pg 223 parag 1
> The various combinations are fully documented in the manpage for
> printf(3), but we'll mention that m is typically the minimum length of a
> field (negative for left justified), and n is precision for exponential
> formats and the maximum length for other formats. Padding is typically
> done with spaces for strings ...
printf "|%-${lcname}s|\n";
------------------------------
Date: Thu, 30 Sep 2004 22:32:38 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: Symbolic algebra
Message-Id: <415cbfdd$2_2@127.0.0.1>
Brian Troutwine wrote:
> I'm trying to write a program to output a Lagrange interpolating
> polynomial.
> http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
>
> So far what I'm getting is output that looks somewhat along the lines of:
>
> ((x-2)(x-3)(x-4)(x-5)(1)/(24))+
> ((x-1)(x-3)(x-4)(x-5)(2)/(-6))+
> ((x-1)(x-2)(x-4)(x-5)(6)/(4))+
> ((x-1)(x-2)(x-3)(x-5)(24)/(-6))+
> ((x-1)(x-2)(x-3)(x-4)(120)/(24))
>
> What I want is to be able to take that and output it in the form of
>
> Ax^n + Bx^(n-1) ... + C
>
> Does anybody have the experience to tell me how to calculate symbolically?
> (Specifically how to implement a symbolic algebra module.)
>
Well, there are some excellent CAS (computer algebra system) programs
available. One good free one is Maxima: http://maxima.sourceforce.net
. It could make quick work of the problem you mention above (hint:
expand). I think at least for now something along those lines would
solve your problem more expeditiously than currently-available Perl
modules. You should also check out newsgroup sci.math.symbolic . A
Perl interface to Maxima might be an excellent way to proceed.
Reinventing a CAS (computer algebra system) in Perl would be quite an
effort, even though Perl should be well-suited for it.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Thu, 30 Sep 2004 22:29:40 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: tr problem
Message-Id: <l0gpl0tegnfpo8l6us1imqmlckngisrbau@4ax.com>
On Thu, 30 Sep 2004 15:33:20 +0200, Christian Winter
<thepoet_nospam@arcor.de> wrote:
>Tad McClellan schrieb:
>> IanW <onedoesnot@needto.know> wrote:
>[...]
>>
>>>Btw, I could shorten that regexp more by doing:
>>>
>>>$_ =~ s/^(\S+)/\U$1/;
>>
>>
>>
>> If short is your goal, then you can improve it even further:
>>
>> s/^(\S+)/\U$1/;
>
>Or even further:
>
>s/^\S+/\U$&/;
At the cost of making all regexes run slower. That's not much of a gain,
especially in this case.
--
Eric Amick
Columbia, MD
------------------------------
Date: Fri, 01 Oct 2004 08:20:09 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: tr problem
Message-Id: <415cf719$0$3638$9b4e6d93@newsread2.arcor-online.net>
Eric Amick schrieb:
> On Thu, 30 Sep 2004 15:33:20 +0200, Christian Winter
> <thepoet_nospam@arcor.de> wrote:
[...]
>>Or even further:
>>
>>s/^\S+/\U$&/;
>
>
> At the cost of making all regexes run slower. That's not much of a gain,
> especially in this case.
Depending on the Perl version used and on the other
code in the script. If its 5.6.x+ and not many other
regexes in the code, the speed loss should only matter
with huge amounts of data processed. If there isn't
any other capturing regex involved, it is even smaller
as one spares $<digit> vars.
But you're right, I should have mentioned that in my
other post.
-Christian
------------------------------
Date: Fri, 01 Oct 2004 03:43:47 +0200
From: peter pilsl <pilsl@goldfisch.at>
Subject: Re: unicode: is decode-process-encode a "good" aproach?
Message-Id: <415cb6d4$1@e-post.inode.at>
>
>>Is it ok to clear the utf-8 flag to make sorting work in a locale-way
>>and set the flag again to make lc() work? Or does this just show that
>>there is something wrong in my script?
>
>
> Hmmmmmmm..... I think this is a bad idea. What if you have chars outside
> ISO8859-1? I would strongly recommend using Encode::encode to convert it
> to ISO8859-1 explicitly, and be prepared to handle errors.
>
thnx. I got around all these problems now by finding an appropriate
locale for my needs : "de_AT.UTF-8". I get the input from a
non-utf8-filehandle, decode and then everythings works smoothly
including sorting, lowercasing, patternmatching (see below). Then I
encode and print out to non-utf8-filehandle again.
> If you read perlunicode it tells you that Unicode and locales currently
> don't play nicely together; I'd probably recommend doing something like
> this:
>
> my $iso = Encode::encode 'iso8859-1' => $utf8;
> {
> use locale;
> do_stuff_with($iso);
> }
> $utf8 = Encode::decode 'iso8859-1' => $iso;
>
> so that you don't try and use unicode data when locales are switched on.
>
perlunicode states that is discouraged, but it also explains a bit what
can happen and and at the end I dont have much of a choice but using
Unicode and locales.
The Data I need to process can definitely include many different
languages and charsets. And the handling (especially collate) should
definitely follow german rules. (german text that can include words from
any other language, including chinese and hindi and other things I never
heard of). And it should be fast ....
Your idea above looks very smart and I'll definitely give it a very
close look. Currently all my locale-stuff work. (almost all - see my
other new posting where there is one construct that makes $s=~/$s/i fail !!)
thnx a lot,
peter
--
http://www2.goldfisch.at/know_list
http://leblogsportif.sportnation.at
------------------------------
Date: Fri, 1 Oct 2004 08:58:04 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Who's responsible for this ?
Message-Id: <2s4dfuF1g49f6U1@uni-berlin.de>
Also sprach Csaba:
> not exp log srand xor s qq qx xor
> s x x length uc ord and print chr
> ord for qw q join use sub tied qx
> xor eval xor print qq q q xor int
> eval lc q m cos and print chr ord
> for qw y abs ne open tied hex exp
> ref y m xor scalar srand print qq
> q q xor int eval lc qq y sqrt cos
> and print chr ord for qw x printf
> each return local x y or print qq
> s s and eval q s undef or oct xor
> time xor ref print chr int ord lc
> foreach qw y hex alarm chdir kill
> exec return y s gt sin sort split
Heh. That must be one of the coolests JAPHs I've seen so far. This JAPH
shows up on perlmonks:
http://www.perlmonks.org/index.pl?node_id=290607
It's not entirely clear though whether the poster was the creator of the
above.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7198
***************************************