[23753] in Perl-Users-Digest
Perl-Users Digest, Issue: 5957 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 19 09:05:45 2003
Date: Fri, 19 Dec 2003 06:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Dec 2003 Volume: 10 Number: 5957
Today's topics:
=?iso-8859-1?Q?Re=3A_Problems_reading_in_=22=A3=22_char <flavell@ph.gla.ac.uk>
Re: Add Files to Zip File (Anno Siegel)
Re: Add Files to Zip File <mikeflan@earthlink.net>
Re: Announcing File::Finder 0.01 <tore@aursand.no>
creating a table report <rkdba@sympatico.ca>
Re: creating a table report <kurzhalsflasche@yahoo.co.uk>
Re: creating a table report <jwillmore@remove.adelphia.net>
Re: creating a table report <invalid-email@rochester.rr.com>
Re: Determine DaysInMonth($month) (Anno Siegel)
Re: Determine DaysInMonth($month) (Tad McClellan)
logonserver value <chris.arnottHATESSPAM@uk.lionbioscience.com>
Re: logonserver value <ThomasKrarz@REMOVEwebCAPS.de>
Re: logonserver value <chris.arnottHATESSPAM@uk.lionbioscience.com>
merge a regex <vervoom@hotmail.com>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Problem with DBI MySQL (UPDATE command) (Steve)
Re: script works, but shows error <jwillmore@remove.adelphia.net>
sum of numbers <chatasos@yahoo.com>
Re: sum of numbers <carsten@welcomes-you.com>
Re: sum of numbers <chatasos@yahoo.com>
Re: sum of numbers (Anno Siegel)
Re: sum of numbers <news@cathars.plus.com>
Re: ticks and FreeBSD <jwillmore@remove.adelphia.net>
Upload field passed through as hidden field not working <jds@nospantrumpetweb.co.uk>
Re: When closing DOS window... <flavell@ph.gla.ac.uk>
Re: When closing DOS window... <spikeywan@bigfoot.com.delete.this.bit>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Dec 2003 11:41:29 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: =?iso-8859-1?Q?Re=3A_Problems_reading_in_=22=A3=22_character_?= =?iso-8859-1?Q?from_a_file_?=
Message-Id: <Pine.LNX.4.53.0312191135400.16555@ppepc56.ph.gla.ac.uk>
On Fri, 19 Dec 2003, Stephen Adam wrote:
> Thanks for the help, that one had me stumped for a while.
If you want to display 8-bit Latin-1 (iso-8859-1) characters in a DOS
window in Win9x, you'd need to translate them into CP850 (assuming a
Western European installation).
USA installations of Win9x use CP437, which gives only partial
coverage of the Latin-1 character repertoire.
In NT-based Windowses (NT4, W2000 etc.) there other options available,
but by default you could do the same thing.
------------------------------
Date: 19 Dec 2003 10:19:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Add Files to Zip File
Message-Id: <brujc4$s1n$1@mamenchi.zrz.TU-Berlin.DE>
Mike Flannigan <mikeflan@earthlink.net> wrote in comp.lang.perl.misc:
>
> Gregory Toomey wrote:
>
> > What do you mean "none worked". No output? Resulting file appears to
> be in wrong format?
> > I've used this module extensively. I suspect you should call
> $zip->writeToFileNamed only once at the end, after you have added all
> the files to the archive.
> >
> > (FWIW i've modified Archive::Zip to do incremental output after each
> member, as the zip archive has its index at the end from the zip file)
> >
> > gtoomey
>
> By "none worked" I mean none would add any other files
> to the zip file.
So what happened? How do you *know* it didn't add files? Did it give
you an error message?
We need to know what happened, not only that you don't like the result.
[snip]
> use warnings;
> use strict;
>
> use File::Find;
> use Archive::Zip;
>
> my $dir = 'c:/Copy2';
>
> find sub {
> ( my $name = $_ ) =~ m/.*(?=\.\w{3})/;
> return if -d;
> return if /Io\.sys/;
> return if /Msdos\.sys/;
> return if /.*\.zip/i;
> print "$name - $& \n";
> my $zip = new Archive::Zip;
You are creating a new, empty archive for each file you encounter,
discarding the one you have created before. So your final archive
will never contain more than one file. Take "new Archive::Zip" out
of the loop.
> # $zip->addFile('file.zip');
> $zip->addFile($File::Find::name);
> # my $member = $zip->addFile('file12.doc', 'file13.doc', 'file15.doc' );
> # $zip->writeToFileNamed("file.zip");
> } => $dir;
> $zip->writeToFileNamed("file.zip");
Anno
------------------------------
Date: Fri, 19 Dec 2003 14:01:13 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Add Files to Zip File
Message-Id: <3FE30570.6D5F3E7F@earthlink.net>
Anno Siegel wrote:
> So what happened? How do you *know* it didn't add files? Did it give
> you an error message?
>
> We need to know what happened, not only that you don't like the result.
The
my $zip = addFile Archive::Zip;
and
my $zip = add Archive::Zip;
said "can't locate object method".
I finally did try the
my $member = Archive::Zip::Member->newFromFile( 'xyz.txt' );
The one below runs fine with no error messages, but
only puts file13.doc into file.zip. I expected it to put
file12.doc and file13.doc and file15.doc into file.zip.
use File::Find;
use Archive::Zip;
my $dir = 'c:/Copy2';
find sub {
( my $name = $_ ) =~ m/.*(?=\.\w{3})/;
return if -d;
return if /Io\.sys/;
return if /Msdos\.sys/;
return if /.*\.zip/i;
print "$name - $& \n";
my $zip = new Archive::Zip;
$zip->addFile('file12.doc', 'file13.doc', 'file15.doc');
$zip->writeToFileNamed("file.zip");
} => $dir;
__END__
------------------------------
Date: Fri, 19 Dec 2003 14:33:45 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Announcing File::Finder 0.01
Message-Id: <pan.2003.12.19.09.09.42.330620@aursand.no>
On Thu, 18 Dec 2003 18:41:16 +0000, Bart Lateur wrote:
>> Oh, please. I don't think the quality of this group goes up by posting
>> uploads to CPAN to it. If everyone starts doing that, half of this
>> group will be filled with it.
> Well, this is a new module, not just a new version. There's a
> difference.
I've always thought comp.lang.perl.announce was the group for posts like
this.
--
Tore Aursand <tore@aursand.no>
"Every man usually has something he can do better than anyone else.
Usually it is reading his own handwriting." -- Unknown
------------------------------
Date: Fri, 19 Dec 2003 06:22:21 -0500
From: "Ravi Krishna" <rkdba@sympatico.ca>
Subject: creating a table report
Message-Id: <9fBEb.20503$CK3.1961974@news20.bellglobal.com>
I am using Perl DBI to generate a report like this which is then mailed to specific users.
WEEKLY REPORT FROM 08-Dec-2003 TO 14-Dec-2003
+--------------------------------------------------------------------------------------------+
|Client |Srches |GS Src|GS BK |GS BK |Total BK|Total BK |Total Tkt|Total Tkt|B/S |T/S |
| | | | |Value($)| |Value($) | |Value($) | (%) |(%) |
+--------------------------------------------------------------------------------------------+
|aaa |17651 |3159 |68 |82,774 |508 |681,638 | | | 2.88| |
|bbb |11106 | | | |15 |17,321 |9 |9,796 | 0.14| 0.08|
+---------+-------+------+------+--------+--------+----------+---------+---------+-----+-----+
I use standard format and write command to generate the above report.
While this serves the purpose adequately, it has limitations.
(a) The mail reader like Outlook must see the mail in plain text form (courier new font).
(b) If I have to add more columns it becomes ugly.
Is there an easy way to include font specifications in the report so that the mail reader
automatically reads this as courier new. Also if I add more columns, will the report just
extend its width automatically or will it wrap around to the next line.
How about using some other method to generate a tabular report. Any ideas?
TIA.
------------------------------
Date: Fri, 19 Dec 2003 13:05:24 +0100
From: Dominik Seelow <kurzhalsflasche@yahoo.co.uk>
Subject: Re: creating a table report
Message-Id: <brupeb$2j5i$1@gwdu112.gwdg.de>
Ravi Krishna wrote:
> I am using Perl DBI to generate a report like this which is then mailed to specific users.
>
> WEEKLY REPORT FROM 08-Dec-2003 TO 14-Dec-2003
> +--------------------------------------------------------------------------------------------+
> |Client |Srches |GS Src|GS BK |GS BK |Total BK|Total BK |Total Tkt|Total Tkt|B/S |T/S |
> | | | | |Value($)| |Value($) | |Value($) | (%) |(%) |
> +--------------------------------------------------------------------------------------------+
> |aaa |17651 |3159 |68 |82,774 |508 |681,638 | | | 2.88| |
> |bbb |11106 | | | |15 |17,321 |9 |9,796 | 0.14| 0.08|
> +---------+-------+------+------+--------+--------+----------+---------+---------+-----+-----+
>
> I use standard format and write command to generate the above report.
>
> While this serves the purpose adequately, it has limitations.
>
> (a) The mail reader like Outlook must see the mail in plain text form (courier new font).
>
> (b) If I have to add more columns it becomes ugly.
>
> Is there an easy way to include font specifications in the report so that the mail reader
> automatically reads this as courier new. Also if I add more columns, will the report just
> extend its width automatically or will it wrap around to the next line.
>
> How about using some other method to generate a tabular report. Any ideas?
>
> TIA.
>
>
Hello Ravi,
if you're writing those tables especially for Microsoft Outlook etc.,
you could use HTML. HTML allows you to specify a font and HTML tables
would also help you to avoid line breaks.
AFAIK, there is no other way to make sure that users of Outlook or OE
will see the e-mail in a fixed-width font.
Weird to use HTML to see plain text...
HTH,
Dominik
------------------------------
Date: Fri, 19 Dec 2003 12:44:35 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: creating a table report
Message-Id: <20031219074435.42818660.jwillmore@remove.adelphia.net>
On Fri, 19 Dec 2003 06:22:21 -0500
"Ravi Krishna" <rkdba@sympatico.ca> wrote:
> While this serves the purpose adequately, it has limitations.
>
> (a) The mail reader like Outlook must see the mail in plain text
> form (courier new font).
>
> (b) If I have to add more columns it becomes ugly.
>
> Is there an easy way to include font specifications in the report so
> that the mail reader automatically reads this as courier new. Also
> if I add more columns, will the report just extend its width
> automatically or will it wrap around to the next line.
>
> How about using some other method to generate a tabular report. Any
> ideas?
Create your output as HTML and then attach the resulting file as a
MIME attachment using MIME::Lite. Because you need a table view and a
particular font, this may fit the bill for you.
I'm sure others have a different way - but that's what I have to
offer.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Bennett's Laws of Horticulture: (1) Houses are for people to
live in. (2) Gardens are for plants to live in. (3) There is
no such thing as a houseplant.
------------------------------
Date: Fri, 19 Dec 2003 13:15:46 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: creating a table report
Message-Id: <3FE2F71C.6080008@rochester.rr.com>
Ravi Krishna wrote:
> I am using Perl DBI to generate a report like this which is then mailed to specific users.
>
> WEEKLY REPORT FROM 08-Dec-2003 TO 14-Dec-2003
> +--------------------------------------------------------------------------------------------+
> |Client |Srches |GS Src|GS BK |GS BK |Total BK|Total BK |Total Tkt|Total Tkt|B/S |T/S |
> | | | | |Value($)| |Value($) | |Value($) | (%) |(%) |
> +--------------------------------------------------------------------------------------------+
> |aaa |17651 |3159 |68 |82,774 |508 |681,638 | | | 2.88| |
> |bbb |11106 | | | |15 |17,321 |9 |9,796 | 0.14| 0.08|
> +---------+-------+------+------+--------+--------+----------+---------+---------+-----+-----+
>
> I use standard format and write command to generate the above report.
>
> While this serves the purpose adequately, it has limitations.
>
> (a) The mail reader like Outlook must see the mail in plain text form (courier new font).
Well, Perl, when used as you stated, simply generates plain ASCII text
(or maybe UTF-8, depending on your settings). So this is really a
question of how Microsoft Outlook interprets plain ASCII text (or maybe
UTF-8), not a question about something involving Perl. You might try a
newsgroup that deals with Microsoft Outlook with this question.
>
> (b) If I have to add more columns it becomes ugly.
"ugly"? What does that mean? Ugly when viewed with what viewer? Perl
can generate a fine report of whatever width you want; the ugliness is
in the viewer, not Perl. You probably mean that your email utility
wraps the text. That is a function of your email generator/viewer, not
Perl. Since most email generators/viewers will wrap text (a feature,
not a bug), you might consider providing two or more tables of
appropriate width to display your data when it is emailed. You might
also consider attaching your nicely formatted tables as attachments, so
the user on the other end can view them with a proper viewer.
>
> Is there an easy way to include font specifications in the report so that the mail reader
> automatically reads this as courier new. Also if I add more columns, will the report just
> extend its width automatically or will it wrap around to the next line.
If you really care about the format, attach a file which can be opened
with a viewer the user will likely have and which supports such ideas as
fonts. HTML, PDF, etc. In Perl, you can
use CGI;
to generate HTML without undue hassle.
>
> How about using some other method to generate a tabular report. Any ideas?
There are thousands of such methods. Take your pick.
> TIA.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 19 Dec 2003 10:31:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Determine DaysInMonth($month)
Message-Id: <bruk2t$s1n$3@mamenchi.zrz.TU-Berlin.DE>
Eric <Eric@nowhere.com> wrote in comp.lang.perl.misc:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnbu3jul.jgc.tadmc@magna.augustmail.com...
> > Eric <Eric@nowhere.com> wrote:
> >
> > [ please include an attribution when you quote someonw ]
> >
> >
> > >> Trolls can write their own code.
> > >
> > > Wasn't trolling. What made you think I was?
> >
> >
> > You said so yourself in:
> >
> > Message-ID: <brs1fb$rc6$1@news6.svr.pol.co.uk>
> >
> > For the sole purpose of annoying you.
> >
> >
> > Posting only to annoy folks is pretty much the definition of trollism.
> >
>
> If you read that whole thread you'd realise you've taken me completely out
> of context. I was being sarcastic.
Yeah. Bad move when your manners are the subject.
> You're probably American I guess.
You think a national slur is going to help your case?
Anno
------------------------------
Date: Fri, 19 Dec 2003 07:01:42 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determine DaysInMonth($month)
Message-Id: <slrnbu5tlm.kv6.tadmc@magna.augustmail.com>
Eric <Eric@nowhere.com> wrote:
> You're probably American I guess.
You're probably new to Usenet I guess.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Dec 2003 10:48:10 -0000
From: "Chris Arnott" <chris.arnottHATESSPAM@uk.lionbioscience.com>
Subject: logonserver value
Message-Id: <KHAEb.4$jk1.231@psinet-eu-nl>
This is the code snippet which tries to grab it from the registry.
$remoteKey=$Registry->{"//$host/CUser/Volatile Environment/logonserver/"} or
die ErrorReport();
$logonsvr= $remoteKey->{"/LOGONSERVER"};
The error reported is "Overlapped I/O operation is in progress". This is
fair enough of course as CUser is in use by the user.
I'm sure there must be a way of grabbing the evironment variable logonserver
form a remote machine.
Thanks,
Chris Arnott.
------------------------------
Date: Fri, 19 Dec 2003 13:27:39 +0100
From: Thomas Kratz <ThomasKrarz@REMOVEwebCAPS.de>
Subject: Re: logonserver value
Message-Id: <3fe2ef76.0@juno.wiesbaden.netsurf.de>
Chris Arnott wrote:
> This is the code snippet which tries to grab it from the registry.
>
> $remoteKey=$Registry->{"//$host/CUser/Volatile Environment/logonserver/"} or
> die ErrorReport();
> $logonsvr= $remoteKey->{"/LOGONSERVER"};
>
> The error reported is "Overlapped I/O operation is in progress". This is
> fair enough of course as CUser is in use by the user.
>
> I'm sure there must be a way of grabbing the evironment variable logonserver
> form a remote machine.
>
> Thanks,
>
> Chris Arnott.
>
>
use Win32;
use Win32::Lanman;
use Data::Dumper;
my $wkst = "MyCompi";
my @info;
unless ( Win32::Lanman::NetWkstaUserEnum($wkst, \@info) ) {
die Win32::FormatMessage(Win32::Lanman::GetLastError());
}
print Dumper(\@info);
It's Better to use the LanManager API than to peek around the registry.
Thomas
--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..
------------------------------
Date: Fri, 19 Dec 2003 12:45:49 -0000
From: "Chris Arnott" <chris.arnottHATESSPAM@uk.lionbioscience.com>
Subject: Re: logonserver value
Message-Id: <1qCEb.6$jk1.68@psinet-eu-nl>
Many thanks Thomas,
"Thomas Kratz" <ThomasKrarz@REMOVEwebCAPS.de> wrote in message
news:3fe2ef76.0@juno.wiesbaden.netsurf.de...
> Chris Arnott wrote:
> > This is the code snippet which tries to grab it from the registry.
> >
> > $remoteKey=$Registry->{"//$host/CUser/Volatile
Environment/logonserver/"} or
> > die ErrorReport();
> > $logonsvr= $remoteKey->{"/LOGONSERVER"};
> >
> > The error reported is "Overlapped I/O operation is in progress". This is
> > fair enough of course as CUser is in use by the user.
> >
> > I'm sure there must be a way of grabbing the evironment variable
logonserver
> > form a remote machine.
> >
> > Thanks,
> >
> > Chris Arnott.
> >
> >
>
> use Win32;
> use Win32::Lanman;
> use Data::Dumper;
>
> my $wkst = "MyCompi";
> my @info;
> unless ( Win32::Lanman::NetWkstaUserEnum($wkst, \@info) ) {
> die Win32::FormatMessage(Win32::Lanman::GetLastError());
> }
>
> print Dumper(\@info);
>
>
> It's Better to use the LanManager API than to peek around the registry.
>
> Thomas
>
> --
> open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
> STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
> print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
> &&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..
------------------------------
Date: Fri, 19 Dec 2003 13:41:38 +0000
From: JS <vervoom@hotmail.com>
Subject: merge a regex
Message-Id: <bruv73$12s4$1@cspc1n11.baplc.com>
Hi,
I have a regex to get the hostname,msgid and client from a postfix log.
However recently some changes were made to our logs so now the line that
comes out could be in 2 forms:
Mar 26 14:06:48 rsl177.bcc.com Message forwarded from rsl177:
postfix/smtpd[38110]: 652C811B1: client=basilhr01b.bcc.com[168.166.43.36]
or
Dec 18 00:08:07 br01ai01 postfix/smtpd[1581100]: 237D75B:
client=basilhr01c.bcc.com[168.166.43.40]
For the first line I had the following regex:
if (/from\s(\w+):.+:\s(\w+):\sclient=(.+)$/){
And for the second line I've written this regex:
if (/(\w+)\s[^\s]*:\s(\w+):\sclient=(.+)$/){
What I'd like to do is merge the regex to catch both lines. Can anyone
see how?
Thanks,
JS.
------------------------------
Date: Fri, 19 Dec 2003 02:22:15 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <3dydnRMay-eqKH-iRVn-uA@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.4 $)
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.
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
"Jeopardy" (because the answer comes before the question), or
"TOFU".
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: 19 Dec 2003 04:16:55 -0800
From: ineverlookatthis@yahoo.com (Steve)
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <f0d57f86.0312190416.7779916c@posting.google.com>
pj_sammie@hotmail.com (Brad) wrote in message news:<2abd2946.0312182134.7bc80d57@posting.google.com>...
> I am trying to update records in a MySQL table using DBI and DBD
> MySQL. I am receiving the following error:
>
> DBD::mysql::db do failed: You have an error in your SQL syntax. Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near '' at line 31 at script.pl line 287, <VARIABLER>
> line 17.
>
> The code where I am trying to update:
> --------
> #Update player data
> $dbh->do("UPDATE archivestats SET
> score=score+'$sqlsession[6]',
> enemyaircraftkills=enemyaircraftkills+$sqlsession[8],
.
..snip..
.
> bails=bails+$sqlsession[35],
> crashes=crashes+$sqlsession[36],
> totaltimeplayed=totaltimeplayed+$sqlsession[38]
> WHERE id=$archiveid");
> --------
That is such an ugly and error-prone way to do it that it doesn't
deserve to live (IMHO).
Make it maintainable, I would use a hash. Here is my suggested
approach:
Steve
#!/usr/bin/perl -w
use strict;
# this hash carries the column names as keys
# and the index for @sqlsession as the values
my %killingstuff =(
score => 6,
enemyaircraftkills => 8,
enemystaticaircraftkills => 9,
enemytankkills => 10,
dictators_dugup => 11,
caves_nuked => 12,
camels_fragged => 14
## and so on..........
);
my @sqlsession;
my $archiveid = 13;
## obviously just for demo purpose
my $SQLline = 'UPDATE archivestats SET ';
foreach my $death_dealt(keys(%killingstuff)){
$sqlsession[$killingstuff{$death_dealt} ] = int(rand(100));
## obviously that line just for demo purpose
$SQLline.="\n$death_dealt = $death_dealt +
$sqlsession[$killingstuff{$death_dealt}], " }
$SQLline.= "WHERE id=$archiveid";
$SQLline=~ s/, WHERE/ WHERE/;
# thats ugly - better ways of loosing last comma ?
# $dbh->do($SQLline);
# but of course place holders would be nicer
print "$SQLline\n";
------------------------------
Date: Fri, 19 Dec 2003 12:01:53 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: script works, but shows error
Message-Id: <20031219070153.0398b691.jwillmore@remove.adelphia.net>
On Fri, 19 Dec 2003 04:43:41 GMT
"J=FCrgen Exner" <jurgenex@hotmail.com> wrote:
> James Willmore wrote:
> > perldoc -q 'cgi'
> > and
> > http://www.perl.org/troubleshooting_CGI.html
> >
> > Read these and if you have any further questions, post them here.
>=20
> Actually no. Rather ask in a newsgroup that actually deals with CGI
True. I was thinking more along the lines of basic Perl. I guess I
just should have left that part out.
Sorry :-(
--=20
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt=20
for more information.
a fortune quote ...
Executive ability is deciding quickly and getting somebody else
to do the work. -- John G. Pollard=20
------------------------------
Date: Fri, 19 Dec 2003 12:11:59 +0200
From: Tassos <chatasos@yahoo.com>
Subject: sum of numbers
Message-Id: <1071828484.212677@athnrd02.forthnet.gr>
Is there a way to find the sum of the following numbers (stored in a file) using a single
line (perl -pe) command?
254257
52658768
19320
135
5070180
14392
7113
24415
34983006
7329
50584
24481
91
8339
14407
------------------------------
Date: Fri, 19 Dec 2003 11:15:54 +0100
From: Carsten Aulbert <carsten@welcomes-you.com>
Subject: Re: sum of numbers
Message-Id: <bruj5h$7mdei$1@ID-213226.news.uni-berlin.de>
Tassos wrote:
> Is there a way to find the sum of the following numbers (stored in a
> file) using a single line (perl -pe) command?
Yes ;-)
Simply write a small script and put all commands on a single line.
CA
------------------------------
Date: Fri, 19 Dec 2003 12:28:41 +0200
From: Tassos <chatasos@yahoo.com>
Subject: Re: sum of numbers
Message-Id: <1071829486.561661@athnrd02.forthnet.gr>
perl -pe 'while (<STDIN>) {$bytes += $_ }; print "$bytes\n";'
worked fine ;-)
Carsten Aulbert wrote:
>
>
>
> Tassos wrote:
>
>> Is there a way to find the sum of the following numbers (stored in a
>> file) using a single line (perl -pe) command?
>
>
> Yes ;-)
>
> Simply write a small script and put all commands on a single line.
>
> CA
------------------------------
Date: 19 Dec 2003 10:25:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sum of numbers
Message-Id: <brujn8$s1n$2@mamenchi.zrz.TU-Berlin.DE>
Tassos <chatasos@yahoo.com> wrote in comp.lang.perl.misc:
> Is there a way to find the sum of the following numbers (stored in a
> file) using a single
> line (perl -pe) command?
>
>
> 254257
> 52658768
> 19320
> 135
> 5070180
> 14392
> 7113
> 24415
> 34983006
> 7329
> 50584
> 24481
> 91
> 8339
> 14407
>
perl -nle '$sum+=$_;END{print$sum}' <numbers
Anno
------------------------------
Date: Fri, 19 Dec 2003 10:41:47 +0000 (UTC)
From: Mike D Cross <news@cathars.plus.com>
Subject: Re: sum of numbers
Message-Id: <bruklb$bvj$1@titan.btinternet.com>
perl -e 'while(<>) { $a=$a+$_}; print "$a\n";exit' < list
Tassos wrote:
> Is there a way to find the sum of the following numbers (stored in a
> file) using a single line (perl -pe) command?
>
>
> 254257
> 52658768
> 19320
> 135
> 5070180
> 14392
> 7113
> 24415
> 34983006
> 7329
> 50584
> 24481
> 91
> 8339
> 14407
>
------------------------------
Date: Fri, 19 Dec 2003 12:35:44 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: ticks and FreeBSD
Message-Id: <20031219073544.0cf2d5c0.jwillmore@remove.adelphia.net>
On Fri, 19 Dec 2003 07:04:11 GMT
Erik Tank <jundy@jundy.com> wrote:
> I am trying to use Proc::ProcessTable (which I assume you meant
> becuase I couldn't find Proc::Table) but I'm not getting any
> information.
[please don't top post]
I'm glad you found the module in spite of my
shortcomings. :-) Sorry :-(
>
> Program:
> #!/usr/bin/perl
should be:
#!/usr/bin/perl -w
include these two lines as well:
use strict;
use diagnostics;
>
> use Proc::ProcessTable;
> use Data::Dumper;
the above two lines are fine.
>
> $t = new Proc::ProcessTable;
> print Dumper($t);
okay. you have declared $t as a new Proc::ProcessTable object. and
you're going to dump $t.
> __END__
>
> I get the following:
> $VAR1 = bless( {}, 'Proc::ProcessTable' );
and you we're expecting ..... what?
>
>
> I've tried this on a FreeBSD 4.9 and 5.1 box and on a Linux RedHat
> 7.3 box.
>
> What am I missing?
You appear to have not read the documentation on Proc::ProcessTable.
Below is an experimental script that I was working on.
---------------------------------------------------------------------
#!/usr/bin/perl -w
use Proc::ProcessTable;
use Date::Manip;
$FORMAT = "%-6s ,%-8s ,%-18s ,%04d ,%-7s ,(%s)\n";
$t = new Proc::ProcessTable;
printf( "%-6s ,%-8s ,%-18s ,%-4s,%-7s,(%-s)\n", "PID", "PPID", "START
TIME",
"TIME", "STATE", "COMMAND" );
foreach $p( @{ $t->table } ) {
printf( $FORMAT, $p->pid, $p->ppid,
UnixDate( scalar( localtime( $p->start ) ), "%m/%e/%y %T" ),
( ( $p->stime ) / 10000 ), $p->state, $p->cmndline );
}
---------------------------------------------------------------------
You should look over the doc for the module, test drive it, salt to
taste :-) The example is nothing more than the example given in the
doc.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
As the trials of life continue to take their toll, remember that
there is always a future in Computer Maintenance. -- National
Lampoon, "Deteriorata"
------------------------------
Date: Fri, 19 Dec 2003 12:59:03 -0000
From: "Julia deSilva" <jds@nospantrumpetweb.co.uk>
Subject: Upload field passed through as hidden field not working
Message-Id: <jBCEb.4812$C71.4122@news-binary.blueyonder.co.uk>
Hi there all,
Perl cgi.pm file upload
my $file = $q->param( "file" );
my $fh = $q->upload( "file" );
I want to
1. Allow user to select .csv file
2. View, print to screen and validate .csv file
3. Process file (add records to MYSQL db)
Got 1 and 2 above working but when I try to pass through
print"<input type='hidden' name='file' value='$file'>\n";
from stage 2 to 3 then I've no longer got the file handle details in <$fh>.
Is there a way around this or am I doing something wrong?
TIA
Jules
------------------------------
Date: Fri, 19 Dec 2003 11:35:27 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: When closing DOS window...
Message-Id: <Pine.LNX.4.53.0312191123370.16555@ppepc56.ph.gla.ac.uk>
On Fri, 18 Dec 2003, R Solberg wrote:
> I would like to learn more about wperl.exe.
It's quite obscure. It differs from perl.exe in just a single bit; I
learned about it right here on the group, it doesn't seem to be very
clearly documented.
> Does anyone know of a man page or something else I can read about
> wperl.exe?
Google suggests http://jenda.krynicky.cz/perl/GUIscripts.html
------------------------------
Date: Fri, 19 Dec 2003 11:18:47 -0000
From: "Richard S Beckett" <spikeywan@bigfoot.com.delete.this.bit>
Subject: Re: When closing DOS window...
Message-Id: <brumtq$2ks$1@newshost.mot.com>
> "Windows cannot shut down this program automatically. It is
> recommended that you exit this program with its quit or exit command"
>
> If a user ignores a warning like that, they get what they deserve :).
Hehehe! Yes I suppose the more you try to make a script fool-proof, the more
inventive the fools will become ;-)
Thanks for all the tips guys.
--
R.
GPLRank +79.699
------------------------------
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 5957
***************************************