[22472] in Perl-Users-Digest
Perl-Users Digest, Issue: 4693 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 06:05:50 2003
Date: Tue, 11 Mar 2003 03: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 Tue, 11 Mar 2003 Volume: 10 Number: 4693
Today's topics:
Re: /proc equivalent in HP-UX (amar)
Re: binary template for OMF? <josef.moellers@fujitsu-siemens.com>
Re: Can Someone Help me with my news page? <tore@aursand.no>
Re: How to use unzip files to current directory <johndoe44@hotmail.com>
Re: How to use unzip files to current directory <noreply@gunnar.cc>
Letting users change their password via web form... <Mandrake@dream-server.com>
Re: Letting users change their password via web form... <abigail@abigail.nl>
Re: Letting users change their password via web form... <jurgenex@hotmail.com>
Re: Merging log files using hash - good idea/possible? <peakpeek@purethought.com>
Re: Merging log files using hash - good idea/possible? <singleantler-news@hotmail.com>
Re: my $x = 100 for 1..3; why is $x undef (Charles DeRykus)
Re: my $x = 100 for 1..3; why is $x undef <s_grazzini@hotmail.com>
Re: Perl > Outlook meeting request (Tony L. Svanstrom)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Prefix matching for filenames? (jtd)
Re: printing a file to a webpage <please@no.spam>
Re: Problem with Term::ReadKey on RedHat <marcin94465@nopls_wp.pl>
Re: remove anything from string except two words (Pynex)
select ip-adress out of pipe delimited file (Pynex)
Re: select ip-adress out of pipe delimited file <s_grazzini@hotmail.com>
Re: select ip-adress out of pipe delimited file <josef.moellers@fujitsu-siemens.com>
Re: select ip-adress out of pipe delimited file (Anno Siegel)
Slow garbage collection of bigass hash? <brundlefly76@hotmail.com>
Re: Slow garbage collection of bigass hash? <brundlefly76@hotmail.com>
Re: Sorting array of hash references by a hash key <please@no.spam>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Mar 2003 22:56:08 -0800
From: amarsantpur@hotmail.com (amar)
Subject: Re: /proc equivalent in HP-UX
Message-Id: <51db1bd3.0303102256.37fa8cdd@posting.google.com>
Hi Martien,
Thanks for the information. I have posted the questio on the
newsgroup suggested by you.
I want to get the USR and SYS time taken by a process id and that
information is present in /proc/<pid>/status file. These files
are available in SUN and Linux OS, but in HP-UX i am not finding
/proc directory. I want to write a perl script which will report
the USR and SYS time taken by a process. I know that there are
executables like time and timex which give the details. But i want
dont want to use any executables.
If you know any information regarding this can you let me know.
Thanks & Regards
Amar
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnb6l0ce.747.mgjv@martien.heliotrope.home>...
> On 8 Mar 2003 02:30:36 -0800,
> amar <amarsantpur@hotmail.com> wrote:
> > Hi,
> >
> > In unix the files for a pid is present in /proc directory.
> > Can anyone tell me the equivalent directory name where i
> > can find all the files for a given pid in HP-UX systems.
>
> I think you mean to post this in a newsgroup that talks about HP UX,
> instead of a Perl newsgroup:
>
> comp.sys.hp.hpux
>
> Martien
------------------------------
Date: Tue, 11 Mar 2003 08:39:57 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: binary template for OMF?
Message-Id: <3E6D92CD.85BDC371@fujitsu-siemens.com>
Lars Unrotin wrote:
> =
> I've been working on a perl script to interpret OMF files [Open Media
> Framwework, not scrollkeeper docs]. I'm new to unpacking binaries, so
> I've tried several different templates with only a little luck.
> =
> I've looked for a spec of this file type [supposedly an open standard]
> and have had no luck.
> =
> Is there a method in perl for figuring out how to interpret a binary
> file? I've had no experience in this regard and would appreciate any
> suggestions.
Despite the fact that there are programs which try to outsmart the user
by thinking they know better what the user wants, Perl by itself,
powerful as it may be, has no built-in intelligence. It does what _you_
tell it to do, although you have several ways to do that (standard
disclaimer!)
If you cannot find a canned interpretation of the OMF file format e.g.
on www.wotsit.org, the best interpreter I have thus far found sits right
behind my eyes and between my ears using the former as sensors.
Perl is a valuable extension to this tool and the binmode and unpack
functions worth looking at.
HTH,
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Tue, 11 Mar 2003 11:53:49 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Can Someone Help me with my news page?
Message-Id: <pan.2003.03.11.01.45.58.199949@aursand.no>
On Tue, 11 Mar 2003 01:10:55 +0000, matt307 wrote:
> www.chaoslegion.netfirms.com/scripts/postnews.htm
I can see from the HTML source on the page that's supposed to list the
items in 'messages.txt' that you're mixing HTML and Perl.
That's no good.
But! I also see that the page is called 'news.cgi', which means that the
_whole_ page seems to be dynamic. What interests me is the contents of
'news.cgi', where I presume the error is.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Tue, 11 Mar 2003 06:40:52 GMT
From: Steve Monty <johndoe44@hotmail.com>
Subject: Re: How to use unzip files to current directory
Message-Id: <3E6D84F5.2060800@hotmail.com>
--------------060703000807080006060100
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Gunnar Hjalmarsson wrote:
> Steve Monty wrote:
>
>> I'm using the system command "unzip" to unzip a file.
>>
>> system ("unzip ../zipdir/zipfile.zip");
>>
>> The problem is that it unzips the file to my cgi directory. What do I
>> need to add to unzip the file to the directory where the zipfile
>> resides? I want to wind up with:
>>
>> zipdir
>> zipfile.zip
>> zipfile1.jpg
>> zipfile2.jpg
>> zipfile3.jpg
>
>
> chdir '../zipdir';
> system (unzip zipfile.zip);
>
> An alternative is to make use of the CPAN module
>
> Archive::Zip
>
> / Gunnar
>
Thank you so much for the help but is that the exact code to use? I
tried what you posted above and it didn't work. I get an error saying
unzip: cannot find ../californiakid90/photos/photo.zip,
../californiakid90/photos/photo.zip.zip or
../californiakid90/photos/photo.zip.ZIP. Content-type: text/html TEST
The code I used was:
##########################
chdir '../californiakid90/photos';
system ("unzip ../californiakid90/photos/photo.zip");
##########################
I have very little coding experience and need a little help here if
you're willing to go a step further. Could you give the exact
code/syntax if this isn't right? Thanks.
--------------060703000807080006060100
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<br>
<br>
Gunnar Hjalmarsson wrote:<br>
<blockquote type="cite"
cite="midb4evh6$1uv67t$1@ID-184292.news.dfncis.de">Steve Monty wrote: <br>
<blockquote type="cite">I'm using the system command "unzip" to unzip a
file. <br>
<br>
system ("unzip ../zipdir/zipfile.zip"); <br>
<br>
The problem is that it unzips the file to my cgi directory. What do I need
to add to unzip the file to the directory where the zipfile resides? I want
to wind up with: <br>
<br>
zipdir <br>
zipfile.zip <br>
zipfile1.jpg <br>
zipfile2.jpg <br>
zipfile3.jpg <br>
</blockquote>
<br>
chdir '../zipdir'; <br>
system (unzip zipfile.zip); <br>
<br>
An alternative is to make use of the CPAN module <br>
<br>
Archive::Zip <br>
<br>
/ Gunnar <br>
<br>
</blockquote>
<br>
Thank you so much for the help but is that the exact code to use? I tried
what you posted above and it didn't work. I get an error saying <br>
<br>
<font face="Times New Roman, Times, serif">unzip: cannot find ../californiakid90/photos/photo.zip,
../californiakid90/photos/photo.zip.zip or ../californiakid90/photos/photo.zip.ZIP.
Content-type: text/html TEST </font> <br>
<br>
The code I used was:<br>
########################## <br>
<font face="Times New Roman, Times, serif">chdir '../californiakid90/photos';<br>
system ("unzip ../californiakid90/photos/photo.zip");</font><br>
########################## <br>
<br>
<br>
I have very little coding experience and need a little help here if you're
willing to go a step further. Could you give the exact code/syntax if this
isn't right? Thanks.<br>
</body>
</html>
--------------060703000807080006060100--
------------------------------
Date: Tue, 11 Mar 2003 10:32:53 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to use unzip files to current directory
Message-Id: <b4kaf7$204bkk$1@ID-184292.news.dfncis.de>
Steve Monty wrote:
>
>>> I'm using the system command "unzip" to unzip a file.
>>>
>>> system ("unzip ../zipdir/zipfile.zip");
>>
>> chdir '../zipdir';
>> system (unzip zipfile.zip);
>
> Thank you so much for the help but is that the exact code to use?
Yes, that was the thought.
> I tried what you posted above and it didn't work. I get an error saying
>
> unzip: cannot find ../californiakid90/photos/photo.zip,
> ../californiakid90/photos/photo.zip.zip or
> ../californiakid90/photos/photo.zip.ZIP. Content-type: text/html TEST
>
> The code I used was:
> ##########################
> chdir '../californiakid90/photos';
> system ("unzip ../californiakid90/photos/photo.zip");
> ##########################
In that case you did not follow my suggestion. Applied to the real
filenames it should be:
chdir '../californiakid90/photos';
system ("unzip photo.zip");
The first line changes the current directory, so you should not use the
same relative path in the system call.
(As pointed out by Drew, an alternative is to state the output directory
directly in the system call.)
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 11 Mar 2003 00:11:47 -0600
From: Mandrake <Mandrake@dream-server.com>
Subject: Letting users change their password via web form...
Message-Id: <v6qvh3eup6hbcb@news.supernews.com>
Hi guys. Anyone have a suggestion as to what I can use to allow users to
change their own passwords? I tried the Expect version, and unfortunately I
don't have time to learn another language so that I can have the script
work with the CGI script when they argue over the users password being too
short, the same, etc. I tried downloading 'poppassd', and it appears to be
grossly out of date (I grab the modules it needs, and when I try it, it
gives me the error 'Your vendor has not defined Socket macro
require_version, used at /usr/lib/perl5/site_perl/5.6.1/LWP/Socket.pm line
45'). I *KNOW* that there are other system admins sitting around out there
who have developed this, because it's sort of inconceivable to think that
all system administrators manually change the passwords for all of their
users. I can deal with the security part of it (checking the previous
password, making sure they're not slipping in something they shouldn't,
etc.), but it's just getting old trying to find such a useful program which
appears to not exist.
Any ideas?
Thanks...
--
Take care,
Randall
------------------------------
Date: 11 Mar 2003 06:39:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Letting users change their password via web form...
Message-Id: <slrnb6r145.n5q.abigail@alexandra.abigail.nl>
Mandrake (Mandrake@dream-server.com) wrote on MMMCDLXXIX September
MCMXCIII in <URL:news:v6qvh3eup6hbcb@news.supernews.com>:
"" Hi guys. Anyone have a suggestion as to what I can use to allow users to
"" change their own passwords? I tried the Expect version, and unfortunately I
"" don't have time to learn another language so that I can have the script
"" work with the CGI script when they argue over the users password being too
"" short, the same, etc. I tried downloading 'poppassd', and it appears to be
"" grossly out of date (I grab the modules it needs, and when I try it, it
"" gives me the error 'Your vendor has not defined Socket macro
"" require_version, used at /usr/lib/perl5/site_perl/5.6.1/LWP/Socket.pm line
"" 45'). I *KNOW* that there are other system admins sitting around out there
"" who have developed this, because it's sort of inconceivable to think that
"" all system administrators manually change the passwords for all of their
"" users. I can deal with the security part of it (checking the previous
"" password, making sure they're not slipping in something they shouldn't,
"" etc.), but it's just getting old trying to find such a useful program which
"" appears to not exist.
Changing passwords over the web is dangerous. My standpoint is that
if you can't figure out how to do it, you're not qualified enough
to do it.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Tue, 11 Mar 2003 07:37:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Letting users change their password via web form...
Message-Id: <7ngba.13094$iq1.11297@nwrddc02.gnilink.net>
Mandrake wrote:
> Hi guys. Anyone have a suggestion as to what I can use to allow users
> to change their own passwords?
Did you read the answer to "perldoc -q password"?
jue
------------------------------
Date: Tue, 11 Mar 2003 05:57:36 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <f5uq6vko7hmeeneq5sducheqitnt5qosjd@4ax.com>
On Mon, 10 Mar 2003 21:06:00 +0000, in comp.lang.perl.misc, Paul Silver <singleantler-news@hotmail.com> wrote:
>Where I work we use Webtrends to analyse our web server stats. We run
>a cluster so it creates two sets of logs, which Webtrends can't handle
>unless we buy a very expensive upgrade, so I'd like to use Perl to
>merge the files in to one so it can be read
Perl has a sort() function
If you have a Unix machine or Unix utilities on a Windows machine,
use the sort program. If the two files are already sorted and just
need to be merged, your sort program might have a merge option -
/usr/bin/sort -m according to the Unix manual I have here
--
Sharon
------------------------------
Date: Tue, 11 Mar 2003 10:37:55 +0000
From: Paul Silver <singleantler-news@hotmail.com>
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <bter6v4pisubgeve1f8bq2e8f23i6b5ud7@4ax.com>
On Mon, 10 Mar 2003 21:23:01 GMT, "dw" <> wrote:
>Assuming it is a log file and the entries in each file are in order, why not
>read one line from each file, print the line with the earlier date, read the
>next line from the file you just printed, repeat until EOF. This will
>prevent you from having to read in the whole file of both logs and creating
>a huge unnecessary hash in memory.
[code example]
Thanks very much for the code dw, I should have guessed that using a
hash would have been too simple. I'll get working on a function for
the date.
Cheers
Paul.
--
Please remove '-news' from address to send e-mail.
------------------------------
Date: Tue, 11 Mar 2003 05:30:31 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: my $x = 100 for 1..3; why is $x undef
Message-Id: <HBKKMv.23D@news.boeing.com>
In article <XWbba.78832$Mh3.23846314@twister.nyc.rr.com>,
Steve Grazzini <s_grazzini@hotmail.com> wrote:
>John Lin <johnlin@chttl.com.tw> writes:
>>
>> use strict;
>> my $x = 100 for 1..3;
>> print defined $x? $x: '<undef>';
>> __END__
>> <undef>
>>
>> Eh? Shouldn't $x be 100? What is the trick here?
>>
>> NOTE: I 'use strict', and $x is not a reserved
>> (globally defined) variable. So I think 'scoping'
>> is not the problem.
>>
>
>Actually it *is* a scoping problem.
>
>The foreach modifier -- unbeknownst to the parser,
>apparently -- creates a scope, and so your print
>statement ends up referring to an undeclared pad
>variable in the "outer" scope.
>
>Pretty good bug; you should report it.
>
> $ perldoc perlbug
>
But doesn't perlsyn imply a scope ... ("The foreach modifier
evaluates once for each element in its LIST, with $_ aliased
to the current element") ?
perl -MO=Deparse <<'END'
> use strict;
> my $x = 100 for 1..3;
> print defined $x? $x: '<undef>';
> END
foreach $_ (1 .. 3) {
my $x = 100;
}
print defined $x ? $x : '<undef>';
- syntax OK
--
Charles DeRykus
------------------------------
Date: Tue, 11 Mar 2003 06:57:30 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: my $x = 100 for 1..3; why is $x undef
Message-Id: <uNfba.79609$Mh3.24050789@twister.nyc.rr.com>
Charles DeRykus <ced@bcstec.ca.boeing.com> writes:
> In article <XWbba.78832$Mh3.23846314@twister.nyc.rr.com>,
> Steve Grazzini <s_grazzini@hotmail.com> wrote:
>>John Lin <johnlin@chttl.com.tw> writes:
>>>
>>> Eh? Shouldn't $x be 100? What is the trick here?
>>>
>>> NOTE: I 'use strict'
>>
>>Pretty good bug; you should report it.
>
> But doesn't perlsyn imply a scope ... ("The foreach
> modifier evaluates once for each element in its LIST,
> with $_ aliased to the current element") ?
>
> perl -MO=Deparse <<'END'
> > use strict;
> > my $x = 100 for 1..3;
> > print defined $x? $x: '<undef>';
> > END
> foreach $_ (1 .. 3) {
> my $x = 100;
> }
> print defined $x ? $x : '<undef>';
> - syntax OK
Sure, there's a nested scope.
But if everything were working correctly, strict
wouldn't let you use $x *outside it*. :)
--
Steve
------------------------------
Date: Tue, 11 Mar 2003 05:31:12 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Perl > Outlook meeting request
Message-Id: <1frn8qw.pc0er61o85gq8N%tony@svanstrom.com>
Dennis Ayzin <da@kclawyers.net> wrote:
> I need to send an e-mail with meeting request to several people. I
> have no problems sending text or html message. The problem comes if I
> create text/calendar header and send it to Outlook. The entire message
> comes up as text e-mail with VEVENT and other coding. I've done some
> research and even tested the system by sending an Outlook request from
> Outlook, then parsing the file and re-sending it again. Every time as
> soon as message is changed by perl or C it comes as text e-mail with
> the entire code in it. In addition if I just copy the file with e-mail
> into the mail folder of the user it comes as Outlook request with no
> problems. Does anyone know how to overcome this problem.
Send me a working and a non-working request and I'll have a look at
them.
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Tue, 11 Mar 2003 02:22:05 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <l_6cna1nltcwAfCjXTWcoQ@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: 10 Mar 2003 23:27:07 -0800
From: adwser@hotmail.com (jtd)
Subject: Re: Prefix matching for filenames?
Message-Id: <c57c103.0303102327.3acf0eb5@posting.google.com>
Ted Zlatanov <tzz@lifelogs.com> wrote in message news:<4nbs0n3p7p.fsf@lockgroove.bwh.harvard.edu>...
> The directory does not keep a sorted list of files, that's the
> problem. You could structure your directories, e.g. 00092 is under
You're right, I'd forgotten that the list is not sorted. Looks like I
might have to use Berkeley db after all...
Thanks everyone for your suggestions!
Jtd
------------------------------
Date: Tue, 11 Mar 2003 08:53:38 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: printing a file to a webpage
Message-Id: <Ywhba.60$KM4.37@newsfep3-gui.server.ntli.net>
matt307 wrote:
> hey all, i am stuck. i have a file messages.txt that i am having users
> append. However i can't figure out how to get messages.txt to be posted
> to my webpage. if this helps, what i am working on is at
> www.chaoslegion.netfirms.com/scripts/postnews.htm You can post the news
> just find its just i cant get the newly updated file to post to the
> website. any help would be appreciated. thanks!
Using a perl CGI script it's easy. Here's just about the most basic approach
you could imagine..
(with no error checking - I leave that to you).
#! /usr/bin/perl
print "Content-type: text/plain\n";
print "\n";
open(FILE, "< messages.txt");
while (<FILE>) { print; }
close(FILE);
exit 0;
Chris
--
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
-- OpenSource (free) e-mail virus protection
------------------------------
Date: Tue, 11 Mar 2003 08:45:46 +0100
From: "mrtn" <marcin94465@nopls_wp.pl>
Subject: Re: Problem with Term::ReadKey on RedHat
Message-Id: <b4k3ui$j8f$1@foka.acn.pl>
"mrtn" <marcin94465@nopls_wp.pl> wrote in message
news:b4foid$47c$1@foka.acn.pl...
> > > the program stops at ReadKey line and doesn't respond to keybord
input.
> I
<snip>
>
> #!/usr/bin/perl -w
> use Term::ReadKey;
> sub test
> {
> ReadMode('cbreak');
> my $key="e";
> while($key ne "q")
> {
> if (defined($char = ReadKey(-1)))
> {
> $key=$char;
> print $key,"\n";
> }
> }
> ReadMode('normal');
> }
> test();
<snip>
Ok, I solved it - tho ReadKey still doesn't work ;) - I just replaced it
with getc(STDIN). I run
perl test.pl
in TermReadKey-2.21 directory and all tests went ok, when I run
perl -Mblib test.pl interactive
program hang up when reading non-blocking input from keyboard - mighty
strange. I also remember that the during installation of ReadKey (in CPAN
shell) - I got information that sgtty was not found.
------------------------------
Date: 10 Mar 2003 22:23:54 -0800
From: pynex@gmx.de (Pynex)
Subject: Re: remove anything from string except two words
Message-Id: <d57585e5.0303102223.77b3a06d@posting.google.com>
> > ( $newstring = $oldstring ) =~ s/Version\s+\d+\.\d+\(\d+\)|XZ-\d+//g;
>
> I think that does exactly the opposite of what the poster wants (but he
> mentioned "cut out", so I'm not quite sure). ;-)
>
> / Gunnar
Yes.
I want the opposite.
$newstring="Version 5.6(17) XZ-6666"
I'm sorry that i'm not able to say exactly what i want, but many
thanks for your help.
------------------------------
Date: 10 Mar 2003 23:48:55 -0800
From: pynex@gmx.de (Pynex)
Subject: select ip-adress out of pipe delimited file
Message-Id: <d57585e5.0303102348.3516b74b@posting.google.com>
Hello !
I've got a pipe delimited file like this:
456|blob|06-20-2001|ping|09-15-2002|192.168.1.1|ABC-1-01|||Hub|Yes|mid|tel
457|blub|06-20-2000|pang|09-21-2002|192.168.1.2|ABG-1-134|||Hub|Yes|mid|tel
458|bleb|06-20-1999|pung|09-23-2002|192.168.1.3|BGF-1-03|||Hub|Yes|mid|tel
459|blib|06-20-2002|peng|09-25-2002|192.168.1.6|L67-1-87|||Hub|Yes|mid|tel
I want to get the IP-Adresses.
At the moment i'm doing it in this way (it not very beautiful, but it works):
$line=<FILE>;
($one,$two,$three,$four,$five,$sic,$seven)=split /[|]/, $line,7;
print "$six\n";
Anybody a better idea ?
Many thanks in advance.
------------------------------
Date: Tue, 11 Mar 2003 07:52:28 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: select ip-adress out of pipe delimited file
Message-Id: <0Bgba.121037$ma2.22784326@twister.nyc.rr.com>
Pynex <pynex@gmx.de> writes:
>
> At the moment i'm doing it in this way (it not very beautiful,
> but it works):
>
> $line=<FILE>;
> ($one,$two,$three,$four,$five,$sic,$seven)=split /[|]/, $line,7;
> print "$six\n";
You mean '$sic' [sic].
--
Steve
------------------------------
Date: Tue, 11 Mar 2003 09:35:51 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: select ip-adress out of pipe delimited file
Message-Id: <3E6D9FE7.436B75CE@fujitsu-siemens.com>
Pynex wrote:
> =
> Hello !
> =
> I've got a pipe delimited file like this:
> =
> 456|blob|06-20-2001|ping|09-15-2002|192.168.1.1|ABC-1-01|||Hub|Yes|mid|=
tel
> 457|blub|06-20-2000|pang|09-21-2002|192.168.1.2|ABG-1-134|||Hub|Yes|mid=
|tel
> 458|bleb|06-20-1999|pung|09-23-2002|192.168.1.3|BGF-1-03|||Hub|Yes|mid|=
tel
> 459|blib|06-20-2002|peng|09-25-2002|192.168.1.6|L67-1-87|||Hub|Yes|mid|=
tel
> =
> I want to get the IP-Adresses.
> =
> At the moment i'm doing it in this way (it not very beautiful, but it w=
orks):
> =
> $line=3D<FILE>;
> ($one,$two,$three,$four,$five,$sic,$seven)=3Dsplit /[|]/, $line,7;
> print "$six\n";
> =
> Anybody a better idea ?
$ip =3D (split(/\|/, $line))[5];
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 11 Mar 2003 08:40:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: select ip-adress out of pipe delimited file
Message-Id: <b4k7dr$5dq$1@mamenchi.zrz.TU-Berlin.DE>
Pynex <pynex@gmx.de> wrote in comp.lang.perl.misc:
> Hello !
>
> I've got a pipe delimited file like this:
>
> 456|blob|06-20-2001|ping|09-15-2002|192.168.1.1|ABC-1-01|||Hub|Yes|mid|tel
> 457|blub|06-20-2000|pang|09-21-2002|192.168.1.2|ABG-1-134|||Hub|Yes|mid|tel
> 458|bleb|06-20-1999|pung|09-23-2002|192.168.1.3|BGF-1-03|||Hub|Yes|mid|tel
> 459|blib|06-20-2002|peng|09-25-2002|192.168.1.6|L67-1-87|||Hub|Yes|mid|tel
>
> I want to get the IP-Adresses.
>
> At the moment i'm doing it in this way (it not very beautiful, but it works):
>
> $line=<FILE>;
> ($one,$two,$three,$four,$five,$sic,$seven)=split /[|]/, $line,7;
> print "$six\n";
A few points:
The typo ($sic for $six) has already been noted.
When the result of split() is assigned to a list, there is no need
to supply the third (limit-) parameter. Split automatically splits
into one more parts than there are list elements. In fact, using
7 here leaves the rest of the line (not only the seventh field) in
$seven, which is arguably wrong.
You don't have to invent variable names for data you don't need. Just
put undef in their place:
( undef, undef, undef, undef, undef, $six) = split /[|]/, $line;
Using a list slice, you can access the 6th element directly:
$six = ( split /[|]/, $line)[ 5];
This would be the standard way of picking out a single field.
Anno
------------------------------
Date: Tue, 11 Mar 2003 07:30:58 GMT
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Slow garbage collection of bigass hash?
Message-Id: <Sggba.201$eb1.12566@typhoon.sonic.net>
I have a subroutine which creates a 400MB hash.
I propogate it with about 2.2M key/value pairs, run some ops on it, it works
fine.
When the hash falls out of scope or when I try to explicitly undef it, or
try to assign () to it, the program just hangs. It has hung for at least 10
minutes before I killed it, I've never seen it complete.
I have never seen this behavior from Perl before - then again, I've never
built a 400MB hash before.
Any ideas?
------------------------------
Date: Tue, 11 Mar 2003 07:49:11 GMT
From: "Seth Brundle" <brundlefly76@hotmail.com>
Subject: Re: Slow garbage collection of bigass hash?
Message-Id: <Xxgba.202$eb1.12790@typhoon.sonic.net>
I just fixed this by recompiling to use the malloc which comes with Perl.
Wacky.
"Seth Brundle" <brundlefly76@hotmail.com> wrote in message
news:Sggba.201$eb1.12566@typhoon.sonic.net...
> I have a subroutine which creates a 400MB hash.
>
> I propogate it with about 2.2M key/value pairs, run some ops on it, it
works
> fine.
>
> When the hash falls out of scope or when I try to explicitly undef it, or
> try to assign () to it, the program just hangs. It has hung for at least
10
> minutes before I killed it, I've never seen it complete.
>
> I have never seen this behavior from Perl before - then again, I've never
> built a 400MB hash before.
>
> Any ideas?
>
>
------------------------------
Date: Tue, 11 Mar 2003 08:47:56 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: Sorting array of hash references by a hash key
Message-Id: <Crhba.58$KM4.28@newsfep3-gui.server.ntli.net>
Thomas D wrote:
> Hello,
>
> I use HTML::Template to generate a web page. When data retrieve from
> database, the output is put in a array of hash references. Something like:
> [
> { name => 'Apple', color => 'Red', shape => 'Round' },
> { name => 'Orange', color => 'Orange', shape => 'Round' },
> ]
> More info at: http://html-template.sourceforge.net/article.html
>
> My question is: after getting the array of hash references, is there a way
> to sort the array by a hash key, eg. key "color"?
>
> Thanks a lot,
> Thomas
@sorted = sort { $a->{color} cmp $b->{color} } @unsorted;
Chris
--
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
-- OpenSource (free) e-mail virus protection
------------------------------
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 4693
***************************************