[22346] in Perl-Users-Digest
Perl-Users Digest, Issue: 4567 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 14 09:06:41 2003
Date: Fri, 14 Feb 2003 06:05:09 -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, 14 Feb 2003 Volume: 10 Number: 4567
Today's topics:
Re: -d not identifying directories (Helgi Briem)
Re: Accessing files in html folder from cgi script (Craig)
Re: amateur needs pattern matching example (Helgi Briem)
detecting a file system on UNIX <aarchi@uk.ibm.com>
Re: detecting a file system on UNIX <nobull@mail.com>
Re: detecting a file system on UNIX <krahnj@acm.org>
Easy filter running for Win32 GUI users (Phil Hibbs)
Re: Easy filter running for Win32 GUI users <tassilo.parseval@post.rwth-aachen.de>
Re: error in comparing user supplied data to database <octomancer@blueyonder.co.uk>
Re: error in comparing user supplied data to database <octomancer@blueyonder.co.uk>
Help with Script <rdavies@kos.net>
Re: Must escape characters for SSI 'include' emulator! (Tad McClellan)
Re: nested file handlers (Tad McClellan)
Re: newbie date comparison (Tad McClellan)
Number of Items in a Hash? <notspam@spamfree.dud>
Re: Number of Items in a Hash? <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Number of Items in a Hash? (Tad McClellan)
Perl Metacharacters and replacement text (Thomas Richards)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
real time log file <spp@monaco377.com>
Re: real time log file <spp@monaco377.com>
Re: real time log file (Tad McClellan)
regex <repairs@ya.com>
Re: stripping part of a string (Tad McClellan)
Re: Using a variable to create a slice <pne-news-20030214@newton.digitalspace.net>
weak references and dclone (via WeakRef and Storable) <Paul.OOO.Gaborit@enstimac.fr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Feb 2003 11:29:13 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: -d not identifying directories
Message-Id: <3e4cd249.603362649@news.cis.dfn.de>
On Fri, 14 Feb 2003 02:10:19 GMT, "Bill Colby"
<bcolby@attbi.com> wrote:
>I am writing a simple CGI script to show directories as hyperlinks. For
>some reason not every directory is being identified when I test the file
>name with the -d operator. This is my script:
<SNIP>
There is no opendir. You need
opendir DIR, $dir or die "Cannot opendir $dir:$!\n";
>@AllFiles = readdir(DIR);
You need to append the directory to the filename as
readdir returns bare filenames.
Something like:
my $file =" $dir/$file";
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 14 Feb 2003 00:25:58 -0800
From: craigdessoy@hotmail.com (Craig)
Subject: Re: Accessing files in html folder from cgi script
Message-Id: <9c4d8212.0302140025.43dc552e@posting.google.com>
"Tore Aursand" <tore@aursand.no> wrote in message news:<pan.2003.02.13.19.39.09.398615@aursand.no>...
> On Thu, 13 Feb 2003 00:29:24 -0800, Craig wrote:
> > $msg = MIME::Lite->new(
> > From =>'me@myhost.com',
> > To =>'craigdessoy@hotmail.com',
> > Cc =>'blah@blahblah.com',
> > Subject =>Tesing testing',
>
> Typo.
>
> > Path =>'var/www/html/despatches.csv'
>
> And you are _sure_ that this path exists _relative_ to where your script
> is being executed? I don't think so. Instead, try to use an absolute
> path to your file;
>
> Path => '/var/www/html/despatches.csv'
>
> Good luck!
thanks guys.
got it working :)
yes i had the path all wrong. you were right i needed the full path,
which in my case was
/home/virtual/domain.com/var/www/html/despatches.csv
cheers~
craig
------------------------------
Date: Fri, 14 Feb 2003 11:25:01 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: amateur needs pattern matching example
Message-Id: <3e4cd17a.603156383@news.cis.dfn.de>
On Thu, 13 Feb 2003 20:44:35 +0100, "Tore Aursand"
<tore@aursand.no> wrote:
>On Wed, 12 Feb 2003 05:40:51 -0800, Mooky Mooksgill wrote:
>> I'd like to parse certain values out of an HTML file [...]
>
>Ooooh! That _is_ really rocket science, believe it or not! Parsing HTML
>is actually very difficult when you think of all the non-standard HTML
>code on the web today.
>
>However, there are modules which comes to rescue; Download HTML::Parser
>from CPAN (www.cpan.org). It's a very handy module.
Well, unless you *are* a rocket scientist, HTML::Parser
can be a little tricky.
HTML::TokeParser provides a simpler interface for
it that many find easier to use
HTML::TokeParser::Simple is even easier.
I am still waiting for
HTML::TokeParser::DeadSimpleEvenForMorons ;-)
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Fri, 14 Feb 2003 09:05:19 -0000
From: "aarchi" <aarchi@uk.ibm.com>
Subject: detecting a file system on UNIX
Message-Id: <b2ibei$rbk$1@sp15at20.hursley.ibm.com>
Hi,
I am working on a number of UNIX systems and use a perl application that
issues a "rm -r /opt/mydir" command.
This command works fine, except when the directory being removed is a
filesystem (it gets listed in the df command or mount command).
Does anyone know if there is a simple way in perl to establish if a
directory represents a file system ?
(The x file tests don't seem to cover this)
Thanks,
aarchi
------------------------------
Date: 14 Feb 2003 09:12:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: detecting a file system on UNIX
Message-Id: <u9u1f7tdoc.fsf@wcl-l.bham.ac.uk>
"aarchi" <aarchi@uk.ibm.com> writes:
> I am working on a number of UNIX systems and use a perl application that
> issues a "rm -r /opt/mydir" command.
>
> This command works fine, except when the directory being removed is a
> filesystem (it gets listed in the df command or mount command).
>
> Does anyone know if there is a simple way in perl to establish if a
> directory represents a file system ?
This is really more a Unix Q than a Perl one. Once you know the
answer to the Unix Q then the Perl bit is trivial.
print "$dir is FS" unless (stat $dir)[0] == (stat "$dir/..")[0];
BTW: This doesn't work for $dir='/'.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 14 Feb 2003 09:35:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: detecting a file system on UNIX
Message-Id: <3E4CB829.7D057116@acm.org>
aarchi wrote:
>
> I am working on a number of UNIX systems and use a perl application that
> issues a "rm -r /opt/mydir" command.
>
> This command works fine, except when the directory being removed is a
> filesystem (it gets listed in the df command or mount command).
>
> Does anyone know if there is a simple way in perl to establish if a
> directory represents a file system ?
if ( (stat '/')[0] != (stat '/opt/mydir')[0] ) {
print "/opt/mydir is a different filesystem.\n";
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 14 Feb 2003 05:44:04 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Easy filter running for Win32 GUI users
Message-Id: <a9ec249e.0302140544.719c6d6b@posting.google.com>
I have written a few perl scripts to reformat text, and I want to make
them easy to use for end users that don't like the Command Line on
their Windows machines.
Currently, the script takes stdin and prints to stdout, but that means
the user has to put '< input.dat > output.dat' at the end of the
command line, which is less than friendly. Ideally, I'd like them to
be able to do it all with the mouse.
Any ideas how I can set this up?
I'm thinking about implementing them as clipboard processors instead
of stream processors. Then, bind the .cmd file to a keypress via a
Start menu shortcut, so the user does Ctrl-A (select all), Ctrl-C
(copy), Ctrl-Shift-T (runs transform script), then Ctrl-V to paste the
transformed text back in. This would not be good for large volumes of
data, though, and some of our files are many megabytes.
------------------------------
Date: 14 Feb 2003 13:55:41 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Easy filter running for Win32 GUI users
Message-Id: <b2isgt$muc$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Phil Hibbs:
> Currently, the script takes stdin and prints to stdout, but that means
> the user has to put '< input.dat > output.dat' at the end of the
> command line, which is less than friendly. Ideally, I'd like them to
> be able to do it all with the mouse.
>
> Any ideas how I can set this up?
>
> I'm thinking about implementing them as clipboard processors instead
> of stream processors. Then, bind the .cmd file to a keypress via a
> Start menu shortcut, so the user does Ctrl-A (select all), Ctrl-C
> (copy), Ctrl-Shift-T (runs transform script), then Ctrl-V to paste the
> transformed text back in. This would not be good for large volumes of
> data, though, and some of our files are many megabytes.
So use Win32::Clipboard. You will have the problem with large files,
though. There's no way around other than using the streamish approach
(that you dislike).
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, 14 Feb 2003 10:48:17 +0000
From: Octo Mancer <octomancer@blueyonder.co.uk>
Subject: Re: error in comparing user supplied data to database
Message-Id: <qT33a.13394$sZ5.4046@news-binary.blueyonder.co.uk>
matt wrote:
<SNIP>
> &OpenMySQL;
> $found_err = 0;
> $dtable = "$prefix"."_members";
> $m_type = "$mtY";
> &DoConv;
> &GetMemberInfo($new_userid);
> if ($d_userid ne "") { $message .= "The 'User ID' you have chosen is
> already on our database.<br>\n"; $found_err++; }
>
---block a---
> $mysql = "SELECT * FROM $dtable WHERE contact='$new_contact'";
> $results = $dbh->prepare($mysql);
> $results->execute();
> $ref = $results->fetchrow_hashref();
> $ccontact = $ref->{'contact'};
> if ($ccontact ne "") { $message .= "The 'Contact Email' you have entered
> is already on our database.<br>\n"; $found_err++; }
---/block a---
>
> if ($new_contact ne "$new_subscribed") {
> $mysql = "SELECT * FROM $dtable WHERE subscribed='$new_subscribed'";
> $results = $dbh->prepare($mysql);
> $results->execute();
> $ref = $results->fetchrow_hashref();
> $ccontact = $ref->{'contact'};
> if ($ccontact ne "") { $message .= "The 'Subscribed Email' you have
> entered is already on our database.<br>\n"; $found_err++; }
> }
---block b---
> $mysql = "SELECT * FROM $dtable WHERE subscribed='$new_contact'";
> $results = $dbh->prepare($mysql);
> $results->execute();
> $ref = $results->fetchrow_hashref();
> $ccontact = $ref->{'subscribe'};
> if ($ccontact ne "") { $message .= "The 'Contact Email' you have entered
> is already on our database.<br>\n"; $found_err++; }
---/block b---
>
> if ($new_contact ne "$new_subscribed") {
> $mysql = "SELECT * FROM $dtable WHERE contact='$new_subscribed'";
> $results = $dbh->prepare($mysql);
> $results->execute();
> $ref = $results->fetchrow_hashref();
> $ccontact = $ref->{'subscribe'};
> if ($ccontact ne "") { $message .= "The 'Subscribed Email' you have
> entered is already on our database.<br>\n"; $found_err++; }
> }
<SNIP>
Hi there,
First of all, "use strict; use warnings; use common-sense;". And you'll
need to view this in a monospaced font for my comments below to line up
with the code.
Your basic problem here is that $d_userid isn't set from the database
before it's tested. It looks like a chunk of code has been excised, or
never written, or stolen by those evil monkeys which always delay the new
linux kernel. If you look at the code which I've marked as "block a" and
"block b", they have several lines before the 'if ($blah ne "") { ... '
line which serve the purpose of finding at least one record in the database
table matching the proposed new user details, if there are any. What you
need to do to fix the script is prefix line 36 with something similar to
the lines below. The exact lines will depend on what the exact name of the
userid field is in the database. I don't use MySQl myself (I'm afraid I bat
for the other side ;-) ), but you can use "SHOW TABLES" to see what tables
there are in the database, and maybe "SHOW table_name" to find out the
schema for a particular table. Presuming you have access to the mysql
command line client.
$mysql = "SELECT * FROM $dtable WHERE userid='$new_userid'";
^^^^^^
needs to be the actual field name
$results = $dbh->prepare($mysql);
$results->execute();
$ref = $results->fetchrow_hashref();
$d_userid = $ref->{'userid'};
^^^^^^
needs to match the field name from the first line
Hope this sorts it out. You're welcome to mail me off list if you like.
Rich
------------------------------
Date: Fri, 14 Feb 2003 11:19:18 +0000
From: Octo Mancer <octomancer@blueyonder.co.uk>
Subject: Re: error in comparing user supplied data to database
Message-Id: <uk43a.13828$sZ5.1043@news-binary.blueyonder.co.uk>
Octo Mancer wrote:
Just realised that the field name for userid would be in the INSERTS at the
bottom of the file. And it is indeed. So the fix I gave should work as is.
Rich
------------------------------
Date: Fri, 14 Feb 2003 07:57:41 -0500
From: "Ronald Davies" <rdavies@kos.net>
Subject: Help with Script
Message-Id: <3e4ce7af@news.kos.net>
Good morning,
I am trying to write a script that will do the following:
Find out the location of the temporary Internet files on the PC. Take a
snapshot of that directory, total up the amount of space used, and delete
only those files that are more than 7 days old from the time the script is
run. Then, after the utility has finished working, take another snapshot of
the directory to show how much space you've freed up. Write the date the
script was run as well as each snapshot recording the before and after
condition of the directory's contents.
I am new to Perl scripting and could use some help with this. I have got the
part about the "date the script was run." I would like to have this script
run on any version or Windows.
Thanks for the help...
Ron
------------------------------
Date: Thu, 13 Feb 2003 23:14:02 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Must escape characters for SSI 'include' emulator!
Message-Id: <slrnb4ouoq.5q0.tadmc@magna.augustmail.com>
James E Keenan <jkeen@concentric.net> wrote:
> "Chris Koenig" <chrisko33@hotmail.com> wrote in message
> news:afcc5932.0302131912.7776f588@posting.google.com...
>> But alas! I haven't
>> yet taken the time to learn Perl, so I've got no clue how to implement
>> it or anything else.
>
> If you haven't taken the time to learn Perl, this is not the appropriate
> forum to pose this question.
The correct forum would be:
http://jobs.perl.org
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 13 Feb 2003 23:11:06 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: nested file handlers
Message-Id: <slrnb4ouja.5q0.tadmc@magna.augustmail.com>
istink <istink@real.bad.com> wrote:
> how can I do this:
By reading the Perl FAQ.
You are supposed to check there *before* posting you know...
> sub mysub{
> open (READ, "i_should_be_private.txt");
> ....
> close (READ);
> # end ##############################
> how can I make READ local and private ?
perldoc -q filehandle
"How can I make a filehandle local to a subroutine?
How do I pass filehandles between subroutines?
How do I make an array of filehandles?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 13 Feb 2003 23:17:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie date comparison
Message-Id: <slrnb4ouv9.5q0.tadmc@magna.augustmail.com>
Jodyman <Jodyman@hotmail.com> wrote:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:b2fl4p$n6o$1@mamenchi.zrz.TU-Berlin.DE...
>> > > > $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;
>> > > ^^^^ ^^^^^^
>> > > Anno, can you explain what his is doing and how it works? Didn't find
>> > > the answer in perldoc -f sprintf.
> That's pretty cool. Where can I read more about this little trick?
The "Foreach Loops" section in:
perldoc perlsyn
> I don't
> recall seeing or reading about this in the camel or any other book for that
> matter.
Books don't matter.
Use the docs Luke!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Feb 2003 12:48:39 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Number of Items in a Hash?
Message-Id: <notspam-1F4695.07484014022003@typhoon1-ge0.nyroc.rr.com>
Newbie question. How can I get a quick tot of the number of items in a
hash? If I use something like $tot = %hashname I get a weird return
value such as 247/153 rather than a single number...
TIA,
Sean
--
Tanta agenda, tantula voluntas.
------------------------------
Date: Fri, 14 Feb 2003 12:57:54 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Number of Items in a Hash?
Message-Id: <Xns93228D641214Delhber1lidotechnet@62.89.127.66>
Sean O'Dwyer wrote:
> Newbie question. How can I get a quick tot of the number of items in a
> hash? If I use something like $tot = %hashname I get a weird return
> value such as 247/153 rather than a single number...
my $no_of_items = keys %hashname;
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Fri, 14 Feb 2003 07:09:50 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Number of Items in a Hash?
Message-Id: <slrnb4pqku.7ui.tadmc@magna.augustmail.com>
Sean O'Dwyer <notspam@spamfree.dud> wrote:
> How can I get a quick tot of the number of items in a
> hash? If I use something like $tot = %hashname I get a weird return
> value such as 247/153 rather than a single number...
my $tot = keys %hashname;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Feb 2003 05:05:31 -0800
From: tom.richards@rocketmail.com (Thomas Richards)
Subject: Perl Metacharacters and replacement text
Message-Id: <f118866.0302140505.78b0de32@posting.google.com>
In the function
s/search_text/replacement_text/g
do metacharcters need to be escaped in the replacement text part?
I tried the following:
SystemMessages="('RP40','RP60','RP44','RP45','RR93')"
perl -p -e "s/¬systemmsgs¬/$SystemMessages/g" out
and was expecting the brackets and single quotes to throw an error.
Please could anyone give me an explanation to how perl treats
metacharacters in the replacement text part?
Thanks
------------------------------
Date: Fri, 14 Feb 2003 05:34:19 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.3 $)
Message-Id: <gHidnXxRH6KmSdGjXTWcrg@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.3 $)
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.perl.com/CPAN-local/authors/Dean_Roehrich/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: Fri, 14 Feb 2003 11:04:22 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <spp@monaco377.com>
Subject: real time log file
Message-Id: <3e4cc15e$0$261$626a54ce@news.free.fr>
Hi all,
I tried without any success to create a real time log file.
My perl program receive the output of the "tail -f /var/log/messages"
command.
My problem is the following:
I cannot manage to write, in real time, in a log file, the output of my
program.
I use formats (write) and print on the output filehandle.
I've even 5 or 6 lines buffered.
I've put $|=1 at the beginning of my script but, it doesn't seem to work.
platform: perl 5.6.0 on kernel 2.4.2-2
If someone as an idea.
Thanks in advance.
Sébastien
------------------------------
Date: Fri, 14 Feb 2003 13:18:13 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <spp@monaco377.com>
Subject: Re: real time log file
Message-Id: <3e4ce0bd$0$28295$626a54ce@news.free.fr>
I solved the problem.
Sébastien Cottalorda wrote:
> Hi all,
>
> I tried without any success to create a real time log file.
>
> My perl program receive the output of the "tail -f /var/log/messages"
> command.
> My problem is the following:
> I cannot manage to write, in real time, in a log file, the output of my
> program.
> I use formats (write) and print on the output filehandle.
> I've even 5 or 6 lines buffered.
> I've put $|=1 at the beginning of my script but, it doesn't seem to work.
>
> platform: perl 5.6.0 on kernel 2.4.2-2
>
> If someone as an idea.
>
> Thanks in advance.
>
> Sébastien
------------------------------
Date: Fri, 14 Feb 2003 07:09:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: real time log file
Message-Id: <slrnb4pqjn.7ui.tadmc@magna.augustmail.com>
[ Text rearranged into a sensible order ]
Sébastien Cottalorda <spp@monaco377.com> wrote:
> Sébastien Cottalorda wrote:
>> My problem is the following:
>> I cannot manage to write, in real time, in a log file, the output of my
>> program.
>> I use formats (write) and print on the output filehandle.
>> I've even 5 or 6 lines buffered.
>> I've put $|=1 at the beginning of my script but, it doesn't seem to work.
> I solved the problem.
Would you mind sharing your solution?
Helping others is what "community" is all about...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Feb 2003 11:11:51 +0100
From: robert <repairs@ya.com>
Subject: regex
Message-Id: <i6gp4vsb26v508fapd8bq9cgnsj3mckt9k@4ax.com>
Hi
here's a regex I'm using to pull some data out of an html file
('/<td
valign="middle"><strong>.*(\d{1,2}.*(?:january|february|march|april|may|june|july|august|september|october|november|december)).*(\d+?).*departs\s*((?:[[:alpha:]]+
*)*)\s*(?:at)\s*(\d{1,2}:\d{2}).*arrives\s*((?:[[:alpha:]]+
*)*)\s*(?:at)\s*(\d{1,2}:\d{2}).*(\d{1,4}\.\d{2}).*(GBP|EUR|CHF).*<\/strong>/iUs'
trouble is when say the (GBP|EUR|CHF) part fails to find a match, the
regex takes forever to finish. I'm assuming that its trying every
combination for all the .* entries, but what technique do I use to
stop this happening?
GunboatDiplomat
------------------------------
Date: Thu, 13 Feb 2003 23:15:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: stripping part of a string
Message-Id: <slrnb4our6.5q0.tadmc@magna.augustmail.com>
Jodyman <Jodyman@hotmail.com> wrote:
> use strict; # Use these so noone yells at you! LOL!
The reason for wearing seatbelts is NOT so noone yells at you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Feb 2003 07:39:48 +0100
From: Philip Newton <pne-news-20030214@newton.digitalspace.net>
Subject: Re: Using a variable to create a slice
Message-Id: <ck3p4vkobn73sn2uaj0r8eqmsbqesmilmf@4ax.com>
On Wed, 12 Feb 2003 22:50:13 +0000 (UTC), "David H. Adler"
<dha@panix.com> wrote:
> Effectively, you're asking for a one-element array slice, with the
> element being at index "1,2,3" - which, of course, doesn't exist.
Wouldn't that be interpreted as 1 when coerced to a number (in order to
fit in the "array index" slot)?
@array[1] certainly exists -- it's a slice of one element.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 14 Feb 2003 13:50:29 +0100
From: Paul GABORIT <Paul.OOO.Gaborit@enstimac.fr>
Subject: weak references and dclone (via WeakRef and Storable)
Message-Id: <r765rn9gbu.fsf@michelange.enstimac.fr>
I use weak references in a complex object. I want to clone my object by
preserving its weak references.
Simple example :
----------------------------------------
use WeakRef;
use Storable qw{dclone};
my $v1 = {};
$v1->{a} = $v1;
weaken($v1->{a});
my $v2 = dclone($v1);
print "v1: $v1\n";
print "v1->{a}: $v1->{a}\n";
print "v2: $v2\n";
print "v2->{a}: $v2->{a}\n";
print "Ok1!\n" if isweak($v1->{a});
print "Ok2!\n" if isweak($v2->{a});
----------------------------------------
This script does not print "Ok2!". The clone thus forgot the weakness of its
reference.
How can I make a correct clone ?
Thank you.
--
Paul Gaborit - <http://www.enstimac.fr/~gaborit/>
Perl en français - <http://www.enstimac.fr/Perl/>
Remove '.OOO' from e-mail address - Supprimez '.OOO' de l'adresse e-mail
------------------------------
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 4567
***************************************