[22001] in Perl-Users-Digest
Perl-Users Digest, Issue: 4223 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 6 00:05:43 2002
Date: Thu, 5 Dec 2002 21:05:11 -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 Thu, 5 Dec 2002 Volume: 10 Number: 4223
Today's topics:
Benchmark testing <jim.bloggs@eudoramail.com>
Building Packages - Override Package Functions - Includ <palladium@spinn.net>
Re: Creating TCP Sockets -- Client Can't Find Server (David Efflandt)
Re: Deleting from arrays <lshaw-usenet@austin.rr.com>
Re: Enumerating %hash keys <jurgenex@hotmail.com>
Re: Enumerating %hash keys <bart.lateur@pandora.be>
Re: Future of Perl as an application server language? (Simon)
Re: Future of Perl as an application server language? <uri@stemsystems.com>
Re: Future of Perl as an application server language? (Simon)
Re: Get Bloomberg data with Perl? <member@dbforums.com>
Re: Getting a URL Page <cboston@e-duct-tape.com>
Re: Getting a URL Page <cboston@e-duct-tape.com>
Re: Getting a URL Page <cboston@e-duct-tape.com>
Re: Getting a URL Page <uri@stemsystems.com>
Re: Getting a URL Page <jurgenex@hotmail.com>
Re: Is there a better way of doing this? <bart.lateur@pandora.be>
Re: MS Exchange and Perl <bart.lateur@pandora.be>
Re: mysql <dmeans@the-means.net>
Re: Re FAQ: How can I capture STDERR from an external c <goldbb2@earthlink.net>
spammers in moderated groups?! <WILKADU@alihqad.nc.us>
Re: use Text::ParseWords; problem with ' (Jay Tilton)
Re: What's the correct way to initialize an array to nu <bart.lateur@pandora.be>
Would appreciate some input - user-defined function (Westy)
Re: Would appreciate some input - user-defined functio <mgjv@tradingpost.com.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 Dec 2002 04:56:43 -0000
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Benchmark testing
Message-Id: <aspamc$t8pub$1@ID-150435.news.dfncis.de>
What's a good way of stepping through a program to find out what's
taking it so long.
Sorry if this is a really obvious question, but I didn't notice it in
any of the FAQ's. Maybe I'm just blind, or stupid or something.. :(
This particular program happens to be a cgi program which hits on a pop3
server. I know the connection to the server is taking a while, but I
don't know how much of the rest is due to my ineptitude. Suspect there
may be a lot of wasted gumf in there and just need a way to find out
which bit is taking so long?
Can this be done?
I can't run mod_perl on this installation. If this is better in the cgi
group, just let me know. Sorry.
--
doofus
------------------------------
Date: Thu, 5 Dec 2002 21:29:05 -0700
From: "Rod" <palladium@spinn.net>
Subject: Building Packages - Override Package Functions - Including Inheritance
Message-Id: <uv0b9qll58qq22@corp.supernews.com>
I have a series of packages I am building. Primarily these are wrappers for
an application framework. The application has many versions. And I want to
limit the amount of package code changes as changes to the framework come
out. For instance.
Version 1.1 Of Application has command :
runme param1
In version 1.2 of Application they added:
runme param1 param2
In version 1.3 of Application they added:
runme param1 param2 -flags input
I would like to write the packages where I have:
Application_1_1.pm
package Application_1_1;
{snip}
@EXPORT= qw(runme runyou runthem);
Application_1_2.pm
package Application_1_2;
use Application_1_1;
{snip}
@EXPORT= qw(runme runyou runthem);
But in Application_1_2.pm I just want to override the runme function and
pass through any unchanged functions.
I hope this makes sense and any thought or suggestions would be appreciated.
Thanks,
Rodney
------------------------------
Date: Fri, 6 Dec 2002 03:53:18 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Creating TCP Sockets -- Client Can't Find Server
Message-Id: <slrnav07pe.3gg.efflandt@typhoon.xnet.com>
On Thu, 05 Dec 2002 01:12:19 GMT, Hal Vaughan <hal@thresholddigital.com> wrote:
> I've posted earler a question about interprocess communication. This is
> similar. I want to have different processes on the same machine, but run
> by different users, communicate with each other. While I've been looking
> at a lot of possibilities, it seems like creating a TCP socket would be the
> best, since I could also use that to communicate with a process on another
> box on the same LAN.
>
> I've copied examples out of the Blue Camel, and I'm running both the client
> and server on the same box (I've also tried them on different boxes -- same
> result). The server process runs and waits. The client process is always
> unable to connect to the server.
Something is broken in your server script. When I run it, 'netstat -atn'
does not show anything associated with that socket. I am not enough an
expert to tell where you went wrong, but the "TCP Servers with IO::Socket"
example in 'perldoc perlipc' works for me. That one is set for port 9000,
which shows up in 'netstat -atn' (0.0.0.0:9000) and I can 'telnet
localhost 9000' (or that port on any other IP on my box besides localhost)
and it responds.
So start with something that works, and work your way to your goal from
there, testing after each change, so you can tell at what point it trips
up.
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Fri, 06 Dec 2002 01:35:11 GMT
From: Logan Shaw <lshaw-usenet@austin.rr.com>
Subject: Re: Deleting from arrays
Message-Id: <j9TH9.123423$8D.3276991@twister.austin.rr.com>
In article <20021205171921.14181.00000159@mb-cj.news.cs.com>, OaxacaGangster wrote:
> When I delete an index from an array, the entry is somehow uninitialized.
> I know the actual list size is not reduced by one unless the deleted element is
> at
> the end of the list.
> When I do an " exists $list[4]", it returns true.
>
> According to Programming Perl by Larry Wall, it should return false.
>
> I am using Perl 5.6
It works for me in perl 5.6.1:
$ perl -le '@x = (1,2,3); delete $x[1]; print exists $x[1] ? 1 : 0'
0
$ perl -version | grep This
This is perl, v5.6.1 built for i386-netbsd
$
But, it's not as great on 5.005:
$ perl -le '@x = (1,2,3); delete $x[1]; print exists $x[1] ? 1 : 0'
delete argument is not a HASH element or slice at -e line 1.
$ perl -version | grep This
This is perl, version 5.005_03 built for i86pc-solaris
$
Seems like it's probably a relatively new feature (I definitely
don't remember it from the "old days"), so I'd move to a newer
version of Perl or just avoid using it. (Sometimes splice() is
what you really want anyway, despite possibly being slower.)
- Logan
--
I'm currently looking for work as a Unix/Solaris
administrator, or Perl/C++/Java developer. Resume
at http://home.austin.rr.com/logan/resume.html.
------------------------------
Date: Fri, 06 Dec 2002 01:06:34 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Enumerating %hash keys
Message-Id: <uKSH9.55160$%r6.48293@nwrddc02.gnilink.net>
Rubber Duck wrote:
> Lets say i have a hash, but i don't know the keys, how can i simply
> dump all of the keys (only) out to the screen/file?
Has been a while since we had a self-answering question :-)
jue
Hint: perldoc -f keys
------------------------------
Date: Fri, 06 Dec 2002 03:46:08 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Enumerating %hash keys
Message-Id: <6b70vusn37suak2pc2c2038lv3lrkplk8e@4ax.com>
Rubber Duck wrote:
>Lets say i have a hash, but i don't know the keys, how can i simply dump all
>of the keys (only) out to the screen/file?
keys %hash
returns a list of all hash keys, and there's
while(my($key, $value) = each %hash) {
...
}
--
Bart.
------------------------------
Date: 5 Dec 2002 15:16:24 -0800
From: simonf@simonf.com (Simon)
Subject: Re: Future of Perl as an application server language?
Message-Id: <3226c4d3.0212051516.4d13a490@posting.google.com>
> then check out stem (stemsystems.com) which sounds like what you are
> looking for. it is a distributed framework and application development
> tool. it is much easier to configure and develop with than java and it
> is in pure perl. it can be used as a web back end with very little
> effort.
Uri,
Thank you for your reply. The site and the idea looks nice, but is
the stemsystems project active? There is no mailing list, and site was
last modified in February. Are there already any projects that are
using Stem for the web back end?
> and stem has a dbi module that lets you have multiple parallel dbi
> connections. also the sql code is stored in the stem config files and
> not in the perl code.
Will it support versioning of data (say, different prices fetched
depending on the date of a bill)? I am yet to find an OORDBMS layer
that does it.
Simon
------------------------------
Date: Thu, 05 Dec 2002 23:20:25 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Future of Perl as an application server language?
Message-Id: <x7of80qchz.fsf@mail.sysarch.com>
>>>>> "S" == Simon <simonf@simonf.com> writes:
>> then check out stem (stemsystems.com) which sounds like what you are
>> looking for. it is a distributed framework and application development
>> tool. it is much easier to configure and develop with than java and it
>> is in pure perl. it can be used as a web back end with very little
>> effort.
S> Thank you for your reply. The site and the idea looks nice, but is
S> the stemsystems project active? There is no mailing list, and site
S> was last modified in February. Are there already any projects that
S> are using Stem for the web back end?
it is an active project. i just haven't had time to hack on the web
site. we recently finished a complex specialized crawler/search engine
which used apache as the front end. stem was both the middleware between
apache and the search engine servers and stem supported parallel
searching. stem was also the framework for the entire crawler which ran
multiple fetch processes and site crawls on multiple boxes.
>> and stem has a dbi module that lets you have multiple parallel dbi
>> connections. also the sql code is stored in the stem config files and
>> not in the perl code.
S> Will it support versioning of data (say, different prices fetched
S> depending on the date of a bill)? I am yet to find an OORDBMS layer
S> that does it.
stem isn't a rdbms or anything like that. the stem::dbi module is a
message passing wrapper around regular dbi so that you can distribute
the DB load to multiple machines and do parallel accesses with no extra
coding at any level.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 5 Dec 2002 16:53:25 -0800
From: simonf@simonf.com (Simon)
Subject: Re: Future of Perl as an application server language?
Message-Id: <3226c4d3.0212051653.7f6d78cd@posting.google.com>
pkent,
> This is not /necessarily/ a mark of quality :-) I mean, Oracle is (I am
> told, read the licence) free for non-commercial personal use, or for
> application development. Apache is non-commercial but I trust it more
> than any commercial web server (although isn't Zeus based on Apache? I
> think Zeus is probably pretty good anyway). Sad to say that cost is not
> always equal to quality.
I did not mean that. Rather, commercial vendors will jump into a
market where there is a chance of middle-to-long-term prosperity. With
enough momentum, it becomes a self-fulfilling prophecy. Famous open
source projects being a notable exception, most of the technology that
surrounds us descends from commercial projects. (Don't even bring up
DARPA and the Internet. :) And even for those open source projects
there are companies doing commercial support. Thus, lack of commercial
interest does not bode well...
>
> P
istence. When the
> > CGI parameters are received, some of them must be ignored, some should
> ...
> > need to create more than one object from a single CGI hash. I have not
> > seen a decent abstraction layer for this at all.
>
> Interestingly that kind of logic that you describe sounds like the
> application-level business logic, and definitely hard to make abstract -
> you the programmer have to marshal the inputs and data into some
> abstract form and _then_ you can use generic back-end classes to "do
> stuff".
XForms. http://www.w3.org/MarkUp/Forms/ Extremely promising approach.
> In any case there are lots of posts here concerned with quite small
> aspects of the language so it's nice to have a post at the other end of
> the spectrum.
In fact, the recommended p5ee mailing list is exactly what I was
looking for. Many like-minded people there.
> > Err... of course I use DBI. However, pretty much everybody agreed at
> > the conference that having raw SQL in your code is bad design. It may
> > be fine for a two-page script, but is unacceptable in an enterprise
> > application. A good persistence layer is a must. IMHO omitted
> > deliberately.
Um, sorry, no slight to anyone intended. This was emphasizing my point
by saying that the previous phrase was not qualified with "IMHO" and
thus represented Absolute Truth. :)
> It's probably less 'omitted' and more 'put somewhere else'. Implementing
> persistence of low level objects like DBI database handles, for example,
> is easy (there's stuff on CPAN to do it, or roll your own if you have
> special needs) ... The persistence is added on by another module - I'd guess that
> under the hood a similar thing is going on in Java.
No argument here. I believed JDBC does the job in Java.
> Also I don't think you actually _need_ SQL in your code to use DBI. I
> await being corrected but there are query abstraction tools. OTOH as a
> fledgling Oracle (and other databases) developer I have the impression
> that if I want to SELECT * from TABLE WHERE foo = bar, the best way to
> express that is simply as 'SELECT * from TABLE WHERE foo = bar'. Values
> of 'best' will vary. It's simple, portable (ANSI SQL), obvious to any of
> the DB developers, DBAs, maintainers, etc. But that's my literally
> humble opinion.
Consider retrieving a collection of objects of different classes (with
inheritance), with each object being spread out over several tables.
With versioning (my pet requirement). With conditional logic (object's
attribute Foo is column Bar in the table A, unless column Baz in table
B is greater than 0, when...). Raw SQL is definitely easier to code,
but it introduces enormous coupling between storage and business
logic.
Simon
------------------------------
Date: Thu, 05 Dec 2002 21:35:55 +0000
From: Tzvi Oppenhimer <member@dbforums.com>
Subject: Re: Get Bloomberg data with Perl?
Message-Id: <2130504.1039124155@dbforums.com>
Originally posted by Michael Robbins
> Has anyone been able to get Bloomberg data into Perl?
>
> Bloomberg has an API, but only has examples for Java, VB, VBA, etc.
>
Hi;
Have you succeed in getting Bloomberg data into Perl?
Thanks
Tzvi
--
Posted via http://dbforums.com
------------------------------
Date: Thu, 5 Dec 2002 19:39:39 -0500
From: "Chris Boston" <cboston@e-duct-tape.com>
Subject: Re: Getting a URL Page
Message-Id: <y6SH9.27060$nd5.5624@news.bellsouth.net>
Here is an example to get just a certain page off of a webserver and write
it to an output file that you can do something with later, or you can pipe
the oupt of wget to another process and dont have to write the file.
#!/usr/bin/perl
$get = "/usr/local/bin/wget --output-document=google.index.html";
$link = "http://www.google.com/index.html";
system("$get $link");
once you install wget just issue wget --help and it will give you more
options than you will probably ever use.
"Kasp" <kasp@epatra.com> wrote in message
news:3b04990d.0212051040.6129b4bf@posting.google.com...
> WGET is a program right? It gets the whole site (maybe there is an
> option just to get one page. But I want to do it in Perl.
> Make a code to fetch the URL page.
>
>
> "Chris Boston" <cboston@e-duct-tape.com> wrote in message
news:<aawH9.23199$bq3.4878@news.bellsouth.net>...
> > Have you tried WGET ?
> >
> > It works great.
> >
> > a2liter
> >
> > "Kasp" <kasp@epatra.com> wrote in message
> > news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> > > Hi!,
> > >
> > > I am a newbie in Perl World and my task is to get a Web Page, given
> > > the URL, and store it's contents in a temp.txt file.
> > > Frankly, I have to do more than that...but as of now getting a web
> > > page is bugging me.
> > >
> > > I want to know how I can do this. Is there a module to do this? (I bet
> > > there is..but dont know).
> > >
> > > A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> > > Thanks
------------------------------
Date: Thu, 5 Dec 2002 19:39:39 -0500
From: "Chris Boston" <cboston@e-duct-tape.com>
Subject: Re: Getting a URL Page
Message-Id: <98SH9.27063$nd5.11764@news.bellsouth.net>
Here is an example to get just a certain page off of a webserver and write
it to an output file that you can do something with later, or you can pipe
the oupt of wget to another process and dont have to write the file.
#!/usr/bin/perl
$get = "/usr/local/bin/wget --output-document=google.index.html";
$link = "http://www.google.com/index.html";
system("$get $link");
once you install wget just issue wget --help and it will give you more
options than you will probably ever use.
"Kasp" <kasp@epatra.com> wrote in message
news:3b04990d.0212051040.6129b4bf@posting.google.com...
> WGET is a program right? It gets the whole site (maybe there is an
> option just to get one page. But I want to do it in Perl.
> Make a code to fetch the URL page.
>
>
> "Chris Boston" <cboston@e-duct-tape.com> wrote in message
news:<aawH9.23199$bq3.4878@news.bellsouth.net>...
> > Have you tried WGET ?
> >
> > It works great.
> >
> > a2liter
> >
> > "Kasp" <kasp@epatra.com> wrote in message
> > news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> > > Hi!,
> > >
> > > I am a newbie in Perl World and my task is to get a Web Page, given
> > > the URL, and store it's contents in a temp.txt file.
> > > Frankly, I have to do more than that...but as of now getting a web
> > > page is bugging me.
> > >
> > > I want to know how I can do this. Is there a module to do this? (I bet
> > > there is..but dont know).
> > >
> > > A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> > > Thanks
------------------------------
Date: Thu, 5 Dec 2002 19:43:43 -0500
From: "Chris Boston" <cboston@e-duct-tape.com>
Subject: Re: Getting a URL Page
Message-Id: <baSH9.27067$nd5.24224@news.bellsouth.net>
Here is an example to get just a certain page off of a webserver and write
it to an output file that you can do something with later, or you can pipe
the oupt of wget to another process and dont have to write the file.
#!/usr/bin/perl
$get = "/usr/local/bin/wget --output-document=google.index.html";
$link = "http://www.google.com/index.html";
system("$get $link");
once you install wget just issue wget --help and it will give you more
options than you will probably ever use.
"Kasp" <kasp@epatra.com> wrote in message
news:3b04990d.0212051040.6129b4bf@posting.google.com...
> WGET is a program right? It gets the whole site (maybe there is an
> option just to get one page. But I want to do it in Perl.
> Make a code to fetch the URL page.
>
>
> "Chris Boston" <cboston@e-duct-tape.com> wrote in message
news:<aawH9.23199$bq3.4878@news.bellsouth.net>...
> > Have you tried WGET ?
> >
> > It works great.
> >
> > a2liter
> >
> > "Kasp" <kasp@epatra.com> wrote in message
> > news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> > > Hi!,
> > >
> > > I am a newbie in Perl World and my task is to get a Web Page, given
> > > the URL, and store it's contents in a temp.txt file.
> > > Frankly, I have to do more than that...but as of now getting a web
> > > page is bugging me.
> > >
> > > I want to know how I can do this. Is there a module to do this? (I bet
> > > there is..but dont know).
> > >
> > > A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> > > Thanks
------------------------------
Date: Fri, 06 Dec 2002 01:01:17 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Getting a URL Page
Message-Id: <x7bs40q7tw.fsf@mail.sysarch.com>
>>>>> "CB" == Chris Boston <cboston@e-duct-tape.com> writes:
don't top post.
and don't triple post.
CB> Here is an example to get just a certain page off of a webserver
CB> and write it to an output file that you can do something with
CB> later, or you can pipe the oupt of wget to another process and
CB> dont have to write the file.
CB> $get = "/usr/local/bin/wget --output-document=google.index.html";
CB> $link = "http://www.google.com/index.html";
CB> system("$get $link");
CB> once you install wget just issue wget --help and it will give you more
CB> options than you will probably ever use.
and running a process from perl when it is not needed is good in what
way?
and that is better than LWP how?
and how well does that handle & in the url?
and why would you pipe the output to another process when you can read
it in perl directly?
and why did you basically write a shell script in perl?
if you can answer those questions, then you might be able to answer
others in this newsgroup.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 06 Dec 2002 01:14:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Getting a URL Page
Message-Id: <HRSH9.55258$%r6.15641@nwrddc02.gnilink.net>
[Please stop blindly full-quoting]
[Please stop posting jeopardy style; rearranged into chronological order]
Kasp wrote:
> "William Alexander Segraves" <wsegrave@mindspring.com> wrote in
> message news:<aslloh$qt2$1@slb4.atl.mindspring.net>...
>> "Kasp" <kasp@epatra.com> wrote in message
>> news:3b04990d.0212041057.5abbb2c1@posting.google.com...
>>> I am a newbie in Perl World and my task is to get a Web Page, given
>>> the URL, and store it's contents in a temp.txt file.
>>> Frankly, I have to do more than that...but as of now getting a web
>>> page is bugging me.
>>>
>>> I want to know how I can do this. Is there a module to do this? (I
>>> bet there is..but dont know).
>>
>> Yes. LWP::Simple.
>>
[....]
>> As a Perl script, that one-liner might look something like:
>>
[...]
>> use LWP::Simple;
[...]
> Thanks for the example. But I am getting an error message.
> "Can't locate LWP/Simple.pm in @INC"
> What should I do now?
Have you considered installing LWP::Simple?
jue
------------------------------
Date: Fri, 06 Dec 2002 03:45:08 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Is there a better way of doing this?
Message-Id: <9470vu0g9c7qqqj81g7hq8am5fab4kllhg@4ax.com>
Jimbo wrote:
>Create an empty array:
>
>my @empty;
>push ( @empty, undef ) foreach ( 1 .. 100 );
$#empty = 99;
or
$empty[99] = undef;
or
@empty = (undef) x 100;
or
@empty[0..99] = ();
Plenty to choose from!
--
Bart.
------------------------------
Date: Fri, 06 Dec 2002 03:55:05 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: MS Exchange and Perl
Message-Id: <vq70vu457i3hav4k0uet0vptn43gil65ck@4ax.com>
Lou Moran wrote:
>I have done some Google searches on the web looking for ways to use
>Perl to access MS Exchange 2000 for bulk changes and such but haven't
>found much.
I'm not an Exchange user... (shudder!), but searching throuigh CPAN? I
found this:
<http://search.cpan.org/author/SMANROSS/Win32-Exchange_v0.032/>
Perhaps it is something?
--
Bart.
------------------------------
Date: Thu, 05 Dec 2002 23:57:55 -0500
From: David Means <dmeans@the-means.net>
Subject: Re: mysql
Message-Id: <pan.2002.12.06.04.57.54.802049.24216@the-means.net>
On Mon, 02 Dec 2002 00:18:29 -0500, Martien Verbruggen wrote:
{ snip }
>> Where is a FAQ on how to construct this stuff for standard SQL
>> connections. Say, Sybase, or MSSQL Server?
>
> Standard? What way do you mean with that?
>
As in "typical".
--
David Means
Different all twisty a of in maze are you, passages little.
------------------------------
Date: Thu, 05 Dec 2002 23:17:19 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Re FAQ: How can I capture STDERR from an external command?
Message-Id: <3DF024CF.4861D37A@earthlink.net>
Peter J. Acklam wrote:
>
> > 8.25: How can I capture STDERR from an external command?
> >
> > [...]
> >
> > To read both a command's STDOUT and its STDERR separately, it's
> > easiest and safest to redirect them separately to files, and then
> > read from those files when the program is done:
> >
> > system("program args 1>/tmp/program.stdout \
> > 2>/tmp/program.stderr");
>
> That's what I need, except I need cycling of the output files,
> like what is done with /var/adm/messages (at least on Solaris).
>
> (By "cycling" I mean that when the size of the first set of output
> files (one for each of stdout and stderr) has reached a certain
> limit, then I close the "program.stdout", shift the list of files,
> so that the old "program.0.stdout" becomes "program.1.stdout", and
> "program.stdout" becomes "program.0.stdout". etc., and then I open
> "program.stdout" for writing again.)
The common term for renaming log files in this way is called "rotating".
> How about if I create two FIFO files and let the output files be
> the two FIFOs? Then, my Perl program can read from the two FIFOs
> and write to the output files and also handle the cycling of the
> regular output files.
>
> What are the dangers and disadvantages of this approach compared
> to using IPC::Open3.
The disadvantages of FIFO files are:
1/ you may have to perform some unportable, system-dependent function or
use of system() to create them.
2/ if your parent program dies for some reason without cleaning up, the
FIFOs will continue to exist in the filesystem until you manually remove
them.
3/ you need a particular place in the filesystem to put them (some
writable directory). This might not be easy to find, if your program is
running with extra-low permissions (as with CGI programs).
4/ Depending on where you stuck your FIFO files, other programs might be
able to read from/write to them, corrupting your data.
5/ Opening a FIFO for reading blocks until there's a writer. Opening a
FIFO for writing blocks until there's a reader. If your child process
fails to start for some reason, your parent process might end up
blocking forever, while trying to open the fifo.
> To me, using FIFO files seems much cleaner, but since no-one else
> seems to have suggested it, I'm afraid there are some disadvantages
> that I have missed... :-)
>
> Comments, anyone?
In what way do FIFO files seem cleaner?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Fri, 06 Dec 2002 00:42:54 GMT
From: Wally <WILKADU@alihqad.nc.us>
Subject: spammers in moderated groups?!
Message-Id: <fuck.moderation.4614410547@xenitec.on.ca>
-----BEGIN xxx SIGNED MESSAGE-----
Ever wish you could spam the moderated groups?
There is every reason to want to. Fewer competing
spams, more attentive readership, better propagation.
Moderators control the newsgroups no longer.
Now you can spam the moderated newsgroups.
For more information, post questions to:
NEWS.ADMIN.NET-ABUSE.EMAIL
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 6.2.7
O6zOpNFu9MEdTFSrUZObB2NTPCJgZkOspbMgYby4oBNqmwUMOM4ZgKpCuYsk/Bpg
XybY3883q2/udZxa6y8ESQTUa+ZnwQtypUxEafF3sHakift+qGWtiIeFQggdqxw/
mzAMnQ0pp9U66Uo7o8h1xn+E8Koqsp9YJ32jbvwDazdNncu/RlIKgpqUG0cjgnvb
19/YVOezTDsXojRwsk2whnA0wRnkoaEOffoycgL2BIQaGoGBUX==
=Skqg
-----END PGP SIGNATURE-----
We cover them, then we slowly attempt Afif and Maify's noisy boat.
------------------------------
Date: Fri, 06 Dec 2002 03:41:12 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: use Text::ParseWords; problem with '
Message-Id: <3df0171f.98662568@news.erols.com>
Alexander Stremitzer <stremitz@consultant.com> wrote:
: I am using the library Text::ParseWords to parse a TAB separated file.
:
: open (RIS,"<ris.good");
: while (<RIS>) {
: chop($_);
chomp() is the preferred tool for removing the trailing record separator.
: my $RIS_LINE = $_;
: push @RISLIST, [ quotewords ('\t', 0, $RIS_LINE) ];
:
: My data look something similar to
:
: 62008286 644719 EDWARDS MONICA D 1958.07.27
: 181490 "GOSNELL, KERMIT, MD"
: 62155755 567426 D'ALONZO WILL M
: 1914.04.07 181489 "GENTCHOS, ERNEST"
:
: The first line works fine, but the ' character in the name of the second
: line causes problems. I don't know why Excel does not qoute the data
: when extracted from a SQL database via MS Query.
Excel quotes a value only when it contains characters it considers
meaningful, like the comma in "GENTCHOS, ERNEST". The gotcha is that it
does not consider the same characters meaningful as does quotewords().
Several choices here.
1. Backslash-escape single quotes in the string before calling
quotewords().
s#'#\\'#g;
push @RISLIST, [ quotewords ('\t', 0, $_) ];
2. Split the record on tab character, then clean up leading/trailing
double-quotes.
push @RISLIST, [
map { s/^"(.*)"$/$1/; $_ } split /\t/
];
3. Export the data from Excel as comma-separated-values, then use the
tools in Text::CSV or Text::CSV_XS to burst the records into fields.
4. Cut out Excel's meddling and the intermediate export step, and get the
data directly from from the database via DBI.
------------------------------
Date: Fri, 06 Dec 2002 03:49:15 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: What's the correct way to initialize an array to null?
Message-Id: <ud70vu4j5pocmc9i2j8222d2a3s3e1sg4o@4ax.com>
Mike Cambray wrote:
>I reuse an array in a script and I'm not sure of the correct way to intialize it
>to null after its been processed.
>@array();
>@array = "";
>@array = ();
>Are any of above valid?
The third one. The second will create one element, an empty string. YOu
can also use "undef @array".
But honestly, why don't you limit the scope of your array, so that next
time through the loop, you'll get a fresh empty copy?
for (1..3) {
my @array; # fresh! empty! new!
push @array, "a";
print "@array\n";
}
--
Bart.
------------------------------
Date: 5 Dec 2002 19:44:28 -0800
From: intlone@hotmail.com (Westy)
Subject: Would appreciate some input - user-defined function
Message-Id: <28b2c540.0212051944.4679f413@posting.google.com>
No errors, goes directly to create_error_page. What's missing? Thanks
for any help!!!!
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI qw(:standard);
use strict;
my ($temp, $convert, $newtemp);
if ($ENV{'QUERY_STRING'} eq "GET"){
$temp = get_input();
}
else{
create_error_page();
}
exit;
sub get_input{
return param( 'Temperature' );
return param( 'convert' );
}
sub create_temp_page{
print "<HTML><HEAD><TITLE>Conversion</TITLE></HEAD>\n";
print "<BODY>\n";
if ( $convert eq "Fahrenheit")
{
$newtemp = 5/9*($temp-32);
print "$temp Fahrenheit equals $newtemp Celcuis\n";
}
else
{
$newtemp = $temp*9/5+32;
print "$temp Celcius equals $newtemp Farhenheit";
}
print "</BODY></HTML>\n";
}
sub create_error_page{
print "<HTML>\n";
print "<HEAD><TITLE>Temperature Conversion Error</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Please return the form and enter a temperature.</H2>\n";
print "</BODY></HTML>\n";
}
<HTML>
<HEAD> <TITLE>Test form for calculation</TITLE> </HEAD>
<BODY>
<CENTER><P><BR><BR>Please choose Fahrenheit to Celcius; or Celcius to
Fahrenheit<BR><BR>
<FORM action="http://webpages/cgi-bin" METHOD="get">
<INPUT TYPE="radio" NAME="convert" VALUE="Fahrenheit"
CHECKED>Fahrenheit to Celcius<BR>
<INPUT TYPE="radio" NAME="convert" VALUE="Celcius">Celcius to
Fahrenheit<BR><BR><BR>
Temperature :<INPUT TYPE="text" NAME="Temperature" size="10"></P>
<P><INPUT TYPE="submit" VALUE="Convert"> <INPUT TYPE="reset"
VALUE="Reset"></P>
</CENTER></FORM>
</BODY>
</HTML>
------------------------------
Date: Fri, 06 Dec 2002 04:01:52 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Would appreciate some input - user-defined function
Message-Id: <slrnav08ct.865.mgjv@verbruggen.comdyn.com.au>
On 5 Dec 2002 19:44:28 -0800,
Westy <intlone@hotmail.com> wrote:
> No errors, goes directly to create_error_page. What's missing? Thanks
> for any help!!!!
>
>
> #!/usr/bin/perl
#!/usr/bin/perl -w
or
use warnings;
> print "Content-type:text/html\n\n";
> use CGI qw(:standard);
> use strict;
use strict;
use CGI qw(:standard);
use CGI::Carp qw(:fatalsToBrowser); # while debugging
print header;
If you use the CGI module, you should use its methods that make it
much easier (and more portable) to write correct headers and HTML.
> my ($temp, $convert, $newtemp);
You should keep your variables scoped to where you need them.
> if ($ENV{'QUERY_STRING'} eq "GET"){
This is your problem.
Instead of environment variables, you should use CGI's methods.
Instead of $ENV{QUERY_STRING} use query_string(). However, that in NOT
the method you want. You want request_method().
However, you don't really have to care about what the request method is.
CGI.pm will do the right thing regardless.
> $temp = get_input();
You assign to $temp, but never use it.
> }
> else{
> create_error_page();
> }
> exit;
> sub get_input{
> return param( 'Temperature' );
> return param( 'convert' );
This second return will never be executed. What are you trying to do
here?
> }
> sub create_temp_page{
> print "<HTML><HEAD><TITLE>Conversion</TITLE></HEAD>\n";
> print "<BODY>\n";
print start_html("Conversion");
See the documentation for the CGI module for all the other useful
calls to create HTML. Trust me, it's much more robust if you use them.
I have not looked at the HTML form. If I were you, I'd make this
program generate the form as well. CGI.pm is very powerful with forms,
and you should probably make use of that. structure your program in
such a way that it generates the form when there are no parameters, it
prints an error message, followed by the form on wrong parameters, and
the result followed by the form on correct parameters. Much nicer, and
it will result in much cleaner code.
Martien
--
|
Martien Verbruggen | If it isn't broken, it doesn't have enough
Trading Post Australia | features yet.
|
------------------------------
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 4223
***************************************