[30608] in Perl-Users-Digest
Perl-Users Digest, Issue: 1851 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 12 06:09:40 2008
Date: Fri, 12 Sep 2008 03:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 12 Sep 2008 Volume: 11 Number: 1851
Today's topics:
Re: binmode blues jidanni@jidanni.org
Re: Extract Numeric values from string <jurgenex@hotmail.com>
Minimal path (fidokomik\)
Re: Minimal path <jurgenex@hotmail.com>
new CPAN modules on Fri Sep 12 2008 (Randal Schwartz)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@seesig.invalid
Re: simple perl script for file uploads ? xhoster@gmail.com
Re: Thoughts on speeding up PDF::API2 <bill@ts1000.us>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Sep 2008 15:43:11 +0800
From: jidanni@jidanni.org
Subject: Re: binmode blues
Message-Id: <87zlmdx10w.fsf@jidanni.org>
bdf> This one is reading from ARGV. What happens when you bin mode that
bdf> filehandle too?
I see. OK, so what should I write instead of just
> binmode STDIN, ":utf8"; binmode STDOUT, ":utf8";
so that it will work no matter if my program is called with any of
$ myprogram < file1
$ myprogram file1
$ myprogram file1 file2 file3 ...
$ myprogram file1 file2 file3 < file4
Ah, for(STDIN,STDOUT,@ARGV){binmode $_, ":utf8"}... shot down real fast:
Bareword "STDIN" not allowed while "strict subs"... as we see, yes I don't
know what I'm doing.
------------------------------
Date: Thu, 11 Sep 2008 21:43:27 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Extract Numeric values from string
Message-Id: <4urjc45am78io5r6jeohos60gbalrtusl2@4ax.com>
Vishal G <v3gupta@gmail.com> wrote:
>On Sep 12, 3:44 am, xhos...@gmail.com wrote:
>> Jürgen Exner <jurge...@hotmail.com> wrote:
>> >VishalG<v3gu...@gmail.com> wrote:
>> > >I have string which contain numbers...
>>
>> > >$str = "30 574 454 67 59 298928 74 4875 8 934"; # in actual string
>> > >there are 112 million values
>>
>> > Wow! A single string of maybe half a gigabyte length? That sounds like
>> > an awfully poor datastructure.
>Actually, I am changing Perl scripts written by someone else and
>changing the data structure is not an option cause other modules
>depends on it
Well, I guess sometimes you are stuck with whatever you are stuck with.
>The information is in the file as I said earlier and read in to this
>data structure. I am trying to split the assembly into parts of
>variable length.
You don't seem to be very familiar with Perl, so let me restate what has
been said earlier:
Perl has a very flexible concept of what constitutes a 'line' in a file.
In particular _YOU_ as a programmer can define, which character is
considered the end-of-line separator/terminator.
Now, if you set the INPUT RECORD SEPARATOR $/ to the space character,
then as far as Perl is concerned each number becomes its own line.
Now you can read your file line by line (i.e. number by number) and Perl
conveniently even keeps a record of which line you just read in the
variable INPUT_LINE_NUMBER $. .
To e.g. print $n numbers, starting with number $start becomes something
like (sketch only, untested):
$. = ' ';
while ($. < $start) {
$dummy = <IN>; #read line (=number) and throw it away
}
for (1..$n) {
print scalar <IN>;
}
The largest piece of data in this code snippet is the list (1..$start)
and even that can be replaced with a while loop, reducing the memory
footprint to a few bytes for just one line (=number) at a time.
jue
------------------------------
Date: Fri, 12 Sep 2008 08:43:23 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Minimal path
Message-Id: <gad36e$4in$1@adenine.netfront.net>
I have array of paths an I need to extract minimal path commont to all of these.
Exple
my @paths=('/vra/test/aaa/', '/var/test/bbb', '/var/test/ccc');
my $minpaths = minpath@paths);
print $minpath;
The result shouu be '/var/test/'
I wrote some fuction to scan 1st, 2nd ... etc char of all array lines and
collect to resutl string if all single chars are sthe same, but this is very
slow. In extreme case @path array can contain thousands of values.
Have anybody some tip fo module or other ida how to do it?
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
-- Posted on news://freenews.netfront.net - Complaints to news@netfront.net --
------------------------------
Date: Fri, 12 Sep 2008 00:40:33 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Minimal path
Message-Id: <v45kc45r4s92fug2sq636fagebkr10nf7m@4ax.com>
"Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz> wrote:
>I have array of paths an I need to extract minimal path commont to all of these.
I bet you are not looking for the minimal (that would be just /) but the
longest common path.
If you consider that paths are just strings with special properties,
then CPAN has a couple of modules to search for the longest common
substring of two strings,
http://search.cpan.org/search?query=common+substring&mode=all.
You may need to adapt the found substring somewhat to accomodate e.g.
/foo/bar1 and foo/bar2 where the desired result would be /foo and not
/foo/bar as for a simple string.
Longest common substring is one of the classic algorithmic problems (I
am too lazy to search the usual suspects like Knuth, Sedgewick or Cormen
et.al.), but your problem is much simpler anyway because your substring
is always anchored to the beginning of the string.
>Exple
>my @paths=('/vra/test/aaa/', '/var/test/bbb', '/var/test/ccc');
>my $minpaths = minpath@paths);
>print $minpath;
>
>The result shouu be '/var/test/'
>
>I wrote some fuction to scan 1st, 2nd ... etc char of all array lines and
>collect to resutl string if all single chars are sthe same, but this is very
>slow. In extreme case @path array can contain thousands of values.
Well, the algorithm should be linear, because for any two given paths
you can determine the longest subset. The final result cannot be longer
than that piece, so you just loop through all paths and shorten the
smallest common denominator step by step.
A totally different approach would be to not treat the paths as strings
but to split() a path into a sequence of directory names and then
compare those fragments using 'eq()', something along the line of
@best = split(+/+, $paths[0]); #initialization,
# first element is as good as any
for (@paths) {
@this = split(+/+);
for ($i = 0; $i < $#best; $i++) {
if ($best[$i] ne $this[$i]) {#difference found
$#best = $i -1; #shorten @best as needed
last; #bail out and continue with next path
}
}
}
I'm sure there some edge cases and some off-by-one errors in that
sketch, but I think the idea is sound.
jue
------------------------------
Date: Fri, 12 Sep 2008 04:42:21 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Sep 12 2008
Message-Id: <K72FqL.226G@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-CPANAuthors-Brazilian-0.02
http://search.cpan.org/~garu/Acme-CPANAuthors-Brazilian-0.02/
We are brazilian CPAN authors
----
Acme-CPANAuthors-Chinese-0.01
http://search.cpan.org/~fayland/Acme-CPANAuthors-Chinese-0.01/
We are chinese CPAN authors
----
Algorithm-Cluster-1.42
http://search.cpan.org/~mdehoon/Algorithm-Cluster-1.42/
Perl interface to the C Clustering Library.
----
CGI-Application-Plugin-Config-Any-0.12
http://search.cpan.org/~mab/CGI-Application-Plugin-Config-Any-0.12/
Add Config::Any Support to CGI::Application
----
CGI-Cookie-XS-0.15
http://search.cpan.org/~agent/CGI-Cookie-XS-0.15/
HTTP Cookie parser in pure C
----
CPAN-WWW-Testers-Generator-0.27
http://search.cpan.org/~barbie/CPAN-WWW-Testers-Generator-0.27/
Download and summarize CPAN Testers data
----
Catalyst-Authentication-Credential-HTTP-0.12
http://search.cpan.org/~bobtfish/Catalyst-Authentication-Credential-HTTP-0.12/
Superseded / deprecated module providing HTTP Basic and Digest authentication for Catalyst applications.
----
Catalyst-Authentication-Credential-HTTP-1.003
http://search.cpan.org/~bobtfish/Catalyst-Authentication-Credential-HTTP-1.003/
HTTP Basic and Digest authentication for Catalyst.
----
Catalyst-Plugin-Authentication-Credential-HTTP-0.12
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-Credential-HTTP-0.12/
Superseded / deprecated module providing HTTP Basic and Digest authentication for Catalyst applications.
----
CatalystX-CRUD-0.30
http://search.cpan.org/~karman/CatalystX-CRUD-0.30/
CRUD framework for Catalyst applications
----
CatalystX-CRUD-Controller-RHTMLO-0.17
http://search.cpan.org/~karman/CatalystX-CRUD-Controller-RHTMLO-0.17/
Rose::HTML::Objects CRUD controller
----
CatalystX-CRUD-Model-RDBO-0.14
http://search.cpan.org/~karman/CatalystX-CRUD-Model-RDBO-0.14/
Rose::DB::Object CRUD
----
CatalystX-CRUD-ModelAdapter-DBIC-0.07
http://search.cpan.org/~karman/CatalystX-CRUD-ModelAdapter-DBIC-0.07/
CRUD for Catalyst::Model::DBIC::Schema
----
CatalystX-CRUD-YUI-0.004
http://search.cpan.org/~karman/CatalystX-CRUD-YUI-0.004/
YUI for your CatalystX::CRUD view
----
Class-Adapter-1.05
http://search.cpan.org/~adamk/Class-Adapter-1.05/
Perl implementation of the "Adapter" Design Pattern
----
DB-CouchDB-Schema-0.3_fix_tests
http://search.cpan.org/~zaphar/DB-CouchDB-Schema-0.3_fix_tests/
A Schema driven CouchDB module
----
DBIx-Class-DynamicDefault-0.03
http://search.cpan.org/~flora/DBIx-Class-DynamicDefault-0.03/
Automatically set and update fields
----
DBIx-Class-RDBOHelpers-0.07
http://search.cpan.org/~karman/DBIx-Class-RDBOHelpers-0.07/
DBIC compat with Rose::DBx::Object::MoreHelpers
----
DBIx-SchemaChecksum-0.09
http://search.cpan.org/~domm/DBIx-SchemaChecksum-0.09/
Generate and compare checksums of database schematas
----
DBIx-SchemaChecksum-0.10
http://search.cpan.org/~domm/DBIx-SchemaChecksum-0.10/
Generate and compare checksums of database schematas
----
DBIx-SchemaChecksum-0.20
http://search.cpan.org/~domm/DBIx-SchemaChecksum-0.20/
Generate and compare checksums of database schematas
----
Data-InputMonster-0.001
http://search.cpan.org/~rjbs/Data-InputMonster-0.001/
consume data from multiple sources, best first; om nom nom!
----
Data-ParseBinary-0.05
http://search.cpan.org/~semuelf/Data-ParseBinary-0.05/
Yet Another parser for binary structures
----
Games-Risk-0.5.3
http://search.cpan.org/~jquelin/Games-Risk-0.5.3/
classical 'risk' board game
----
HTTP-DAV-0.34
http://search.cpan.org/~opera/HTTP-DAV-0.34/
A WebDAV client library for Perl5
----
IO-Handle-Record-0.08
http://search.cpan.org/~opi/IO-Handle-Record-0.08/
IO::Handle extension to pass perl data structures
----
LCFG-Build-Skeleton-0.0.6
http://search.cpan.org/~sjquinney/LCFG-Build-Skeleton-0.0.6/
LCFG software package generator
----
LCFG-Build-Skeleton-0.0.7
http://search.cpan.org/~sjquinney/LCFG-Build-Skeleton-0.0.7/
LCFG software package generator
----
Lyrics-Fetcher-AZLyrics-0.04
http://search.cpan.org/~bigpresh/Lyrics-Fetcher-AZLyrics-0.04/
Get song lyrics from www.azlyrics.com
----
OpenGL-PLG-0.03
http://search.cpan.org/~garu/OpenGL-PLG-0.03/
Create, manipulate and render PoLyGon objects and files
----
Padre-0.08
http://search.cpan.org/~szabgab/Padre-0.08/
Perl Application Development and Refactoring Environment
----
Perlwikipedia-1.3.4
http://search.cpan.org/~dcollins/Perlwikipedia-1.3.4/
a Wikipedia bot framework written in Perl
----
Rose-DBx-Garden-0.15
http://search.cpan.org/~karman/Rose-DBx-Garden-0.15/
bootstrap Rose::DB::Object and Rose::HTML::Form classes
----
Rose-DBx-Garden-Catalyst-0.09
http://search.cpan.org/~karman/Rose-DBx-Garden-Catalyst-0.09/
plant Roses in your Catalyst garden
----
Rose-HTMLx-Form-Field-Serial-0.001
http://search.cpan.org/~karman/Rose-HTMLx-Form-Field-Serial-0.001/
represent auto-increment columns in a form
----
Rose-HTMLx-Form-Related-0.07
http://search.cpan.org/~karman/Rose-HTMLx-Form-Related-0.07/
RHTMLO forms, living together
----
Search-QueryParser-SQL-0.005
http://search.cpan.org/~karman/Search-QueryParser-SQL-0.005/
turn free-text queries into SQL WHERE clauses
----
Sub-Uplevel-0.2002
http://search.cpan.org/~dagolden/Sub-Uplevel-0.2002/
apparently run a function in a higher stack frame
----
Sys-Filesystem-ID-1.06
http://search.cpan.org/~leocharre/Sys-Filesystem-ID-1.06/
----
Sys-Statistics-Linux-0.38
http://search.cpan.org/~bloonix/Sys-Statistics-Linux-0.38/
Front-end module to collect system statistics
----
Template-Provider-Preload-0.02
http://search.cpan.org/~adamk/Template-Provider-Preload-0.02/
Preload templates to save memory when forking
----
Template-Refine-0.02
http://search.cpan.org/~jrockway/Template-Refine-0.02/
refine HTML
----
Text-Template-Simple-0.54_05
http://search.cpan.org/~burak/Text-Template-Simple-0.54_05/
Simple text template engine
----
ex-lib-0.01
http://search.cpan.org/~mons/ex-lib-0.01/
The same as lib, but makes relative path absolute.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Fri, 12 Sep 2008 07:15:22 GMT
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
Message-Id: <eGoyk.105$c45.93@nlpi065.nbdc.sbc.com>
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.8 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://www.rehabitation.com/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 that they do
know and are being the "bad kind" of Lazy.
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan and many others on the comp.lang.perl.misc newsgroup.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 12 Sep 2008 04:59:26 GMT
From: xhoster@gmail.com
Subject: Re: simple perl script for file uploads ?
Message-Id: <20080912005930.466$1v@newsreader.com>
Jack <jack_posemsky@yahoo.com> wrote:
> >
> > I want to add the ability to post a file from a browser to a server.
By post you mean the POST method of HTTP?
> > Example is craigslist where the user selects an image file and uploads
> > it to their servers.
I'm not familiar with that feature of Craig's list. You could look at the
page source and see how they do it.
> > Thats it, its very simple and preferably not via
> > a form post
What distinguishes a "form" POST from some other kind of POST?
> > since I am using that already with my ajax code thats
> > populating my HTML + perl logic into a form, and its advisable to only
> > post to one form,
What does it mean to POST to a form? Browsers usually POST *from* forms.
> > not more than 1.
Who says that only this is advisable? Who is advising you?
> Hi I answered Xho's question. Can anyone help here with real example
> Perl code (NOT CGI)
In what way is Perl CGI not really Perl? If we are arbitrary not allowed
to use the best tool for the job, I have to wonder what else you will
arbitrarily disallow. Are we to spend our time coming up with solutions
using common modules, only to be told you don't those, either?
> that works for browser - server file uploads ?
Browsers generally do not run Perl. If you want to get the browser to POST
without using the built-in (to the browser) HTTP form submission, then you
will need to use a language which runs in the browser to accomplish this.
You seem to be burdened with an excessive number of misconceptions.
Perhaps you should try JavaScript.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 12 Sep 2008 01:42:04 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: Thoughts on speeding up PDF::API2
Message-Id: <52114108-4e1a-411c-a4e7-f1eb41ac4fe5@z72g2000hsb.googlegroups.com>
On Sep 11, 11:27=A0pm, xhos...@gmail.com wrote:
> Bill H <b...@ts1000.us> wrote:
> > In a recent post I asked about speeding up a perl script that uses
> > PDF::API2. I did some profiling of the code and see that the vast
> > majority of the time (about 90%) is used in going through all
> > the .pm's in the PDF::API2 library. Once it gets past all of the
> > initialization, my code that uses the api goes very fast, creating a
> > 20+ pdf document with seperate image thumbnail files of each page (via
> > imagemagik) in less than 2 seconds.
>
> If 10% of the time is spent doing something that takes 2 seconds,
> then 100% of the time is 20 seconds and the module loading must be taking
> almost 18 seconds. =A0That is outrageous on anything modestly recent
> computer. On my machine, loading PDF::API2 takes ~0.5 seconds.
>
> One possible problem is if the PDF::API2 location install show up late in
> @INC, and the stuff earlier in @INC is on slow network drives. =A0For eac=
h of
> the files it opens as part of loading PDF:API2, it has to "stat" its way
> through the entire @INC list before finally finding it.
>
> > In a meeting we were having tonight we was tossing around the idea of
> > having the program go through its initial setup and then "pause" to
> > wait for a signal to create a pdf file, then create the pdf, images
> > and then go back to the pause. Basically running all the time as a
> > service. Anyone see any reason why this would be a bad idea?
>
> Nope. =A0Sounds like a good idea. =A0Working out the "signal" could be tr=
icky.
>
> > We further started wondering, instead of pausing, then running on a
> > signal and then going back to pause for next signal to make a pdf,
> > would it be possible to fork off a child at that point and have the
> > child create the pdf / images and end, while the parent stayed at the
> > pause position waiting for another signal to fork off a child.
>
> Yes, you can do that, but it probably wouldn't be worthwhile. =A0Since th=
e
> make a pdf part is fast, what is the point of parallelizing it? =A0It wou=
ld
> add complexity for probably little to no benefit.
>
> > If we
> > forked off a child, would it start from the begining of the script or
> > would it start at the same place (probably next line) in the perl
> > script it was forked off of?
>
> The new process and the old process start/continue at the same place. =A0=
It
> isn't the next line, it is the" returning" of the fork.
> $x=3Dfork();
>
> The fork itself only happens in the parent, but the assignment to $x
> happens in both the parent and the child.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicat=
e
> this fact.
Thanks Ben, Xho for your comments. I am glad to see the idea we had
wasn't that far fetched.
On the signal to do something, the part of the website that calls the
perl program using PDF::API2 is in php and uses php sessions to talk
back and forth to each other. I saw a perl module that let you access
php sessions and wonder about using that method to send the signal.
Has anyone had any experience using php sessions in perl? Are they
continously updated? Or can anyone think of a better way of signaling
the perl script from another program?
Bill H
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1851
***************************************