[24055] in Perl-Users-Digest
Perl-Users Digest, Issue: 6252 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 13 06:05:41 2004
Date: Sat, 13 Mar 2004 03: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 Sat, 13 Mar 2004 Volume: 10 Number: 6252
Today's topics:
ActivePerl and WSH debugger - Does it work? <NoOne@None.Com>
Re: C expressions in Perl <jwillmore@remove.adelphia.net>
Re: C expressions in Perl <tore@aursand.no>
Re: call a cgi script from a cgi script <jwillmore@remove.adelphia.net>
Re: formmail problem <jwillmore@remove.adelphia.net>
how to reset a variable (Novice)
Re: how to reset a variable <roland@astrofoto.org>
Re: how to reset a variable (Jay Tilton)
Re: how to reset a variable <tore@aursand.no>
Re: how to reset a variable <jwillmore@remove.adelphia.net>
Re: how to reset a variable <jwillmore@remove.adelphia.net>
Re: HTTP 1.1 module (Malcolm Dew-Jones)
Re: HTTP 1.1 module <jwillmore@remove.adelphia.net>
Re: HTTP 1.1 module <chatiman@free.fr>
Re: Image-Magick.ppd installation <kalinaubears@iinet.net.au>
Re: Image-Magick.ppd installation <ha@hago-ziegler.de>
open(filehandle... is failing <dave@nowhere.com>
Re: open(filehandle... is failing <kkeller-usenet@wombat.san-francisco.ca.us>
Re: open(filehandle... is failing <gnari@simnet.is>
Re: open(filehandle... is failing <nospam@bigpond.com>
Re: open(filehandle... is failing <nospam@bigpond.com>
Re: open(filehandle... is failing <dave@nowhere.com>
Re: open(filehandle... is failing <kkeller-usenet@wombat.san-francisco.ca.us>
Re: open(filehandle... is failing <jwillmore@remove.adelphia.net>
Re: Perl module for analyzing log files (Krishna Srinivasan)
Re: Perl module for analyzing log files <tore@aursand.no>
Re: Regex to match simple line of XML (ac)
Re: Regex to match simple line of XML (Jay Tilton)
Re: Regex to match simple line of XML <tore@aursand.no>
Re: SCALAR(0x82e1024) <jwillmore@remove.adelphia.net>
Re: SCALAR(0x82e1024) <tore@aursand.no>
Re: Text editor implemented in Perl <bik.mido@tiscalinet.it>
Re: Text editor implemented in Perl <jkrugman@yahbitoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 13 Mar 2004 01:09:02 -0800
From: Robert K. Young <NoOne@None.Com>
Subject: ActivePerl and WSH debugger - Does it work?
Message-Id: <8re550ddgkqv8ktu73vcjreg5psa35gked@4ax.com>
I've written a few thousand lines of perl (Linux) over the last couple
of years, and about twice as much VBScript (W2K).
I'm now moving most of my "stuff" to an XP pro box. I have ActiveState
Perl (5.8.3) installed and I can execute perl script as extected with:
C:\Src\Perl>perl myscript.pls
of course I can also debug with:
C:\Src\Perl>perl -d myscript.pls
The problem is that the perl debugger is a little limmited comparred
to the really nice debugger available for VBScript or JScript running
under WSH.
Fo example:
C:\Src\Java>CScript /X myscript.js
Byings up full featured GUI debugger with a window(s) containing the
source file(s) with the current execution line highlighted. A window
showing immediate, local, and auto variables (tabbed). A window for
watched variables, a window showing the parent and child threads of
the process being debugged, and of course the call stack. Additionally
there are buttons and keystrokes to step into/over/out of functions as
well as single step.
There's more but you get the idea, the point being that the native
perl debugger really feels pretty cramped, and more than a little
painful, compared to the debugger available for the other scripting
languages under Windows.
From what I've been able to research it _sounds_ like the PerlScript
that is part of ActiveState's ActivePerl IS compatible with WSH:
__________________________________________________
ActivePerl documentation: index.html
[Windows Scripting -> Windows Script Host ]
Windows Script Host (WSH) is a scripting host for ActiveX Scripting
Engines such as PerlScript. As a host, WSH enables you to use the
scripting language from the command-line and from within the Windows
desktop with the WSH features.
In order to execute a WSH-file, use one of two executable files
depending on your needs: WScript.exe for Windows desktop files and
CScript.exe is for command-line scripts.
[ Windows Specific -> PerlScript]
What is PerlScript?
PerlScript is an ActiveX scripting engine that allows you to use Perl
with any ActiveX scripting host. At this time, ActiveX scripting hosts
include:
Internet Information Server 3.0/4.0/5.0
Peer Web Services 3.0/4.0
Microsoft Internet Explorer 5.0x
Windows Scripting Host
What do I need to run PerlScript?
ActivePerl
an ActiveX scripting host (see above)
Windows 2000/NT/9x
Perl scripts!
_________________________________________________________
Okay...so the way I read it, the docs say this should work:
C:\Src\Perl>CScript Test.pls
And as a matter of fact it does, however this:
C:\Src\Perl>CScript /X Test.pls
Gives the following error:
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
CScript Error: Can't find script engine "PerlScript" for script
"C:\Src\Perl\Test.pls".
Is there some way to make this work, or is what I'm trying to do;
debug PerlScript under the native WSH debugger, just not possible?
Suggestions, relevant references, or authoratative answers
appreciated.
TIA
Bob Young
San Jose, CA.
------------------------------
Date: Sat, 13 Mar 2004 04:13:26 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: C expressions in Perl
Message-Id: <pan.2004.03.13.09.13.25.154050@remove.adelphia.net>
On Fri, 12 Mar 2004 20:41:24 +0000, Joe wrote:
> Can I do this in Perl?
>
> Sub F{
> return true'
> }
>
> if (!F()) {do something}
`perldoc perlsub`
This gives you the documentation on subroutines in Perl.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
When someone says "I want a programming language in which I need
only say what I wish done," give him a lollipop.
------------------------------
Date: Sat, 13 Mar 2004 11:06:43 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: C expressions in Perl
Message-Id: <pan.2004.03.13.10.06.31.795572@aursand.no>
On Fri, 12 Mar 2004 20:41:24 +0000, Joe wrote:
> Can I do this in Perl?
>
> Sub F{
> return true'
> }
>
> if (!F()) {do something}
Not excactly. The closest thing would be something like this;
sub F {
return 1;
}
unless ( F() ) {
# do something
}
Personally, I prefer 'unless' instead of a "negative 'if'". It's easier
you read, and it's more "plain English" for me.
You could also define 'true' as a constant (although I would suggest that
you uppercase all constants);
use constant {
FALSE => 0,
TRUE => 1,
};
sub F {
return TRUE;
}
unless ( F() ) {
# do something
}
--
Tore Aursand <tore@aursand.no>
"A car is not the only thing that can be recalled by its maker." --
Unknown
------------------------------
Date: Sat, 13 Mar 2004 04:41:57 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: call a cgi script from a cgi script
Message-Id: <pan.2004.03.13.09.41.56.227633@remove.adelphia.net>
On Fri, 12 Mar 2004 12:15:37 -0800, Joe wrote:
> How do I do this?
>
> I want my cgi script to call a cgi script with a argument.
>
> is:
>
> my $cmd = "perl ".$SCRIPT_URL ."?".$POLL_CODE_SURVEY."|";
>
> open CMD, $cmd;
>
> right?
Nope. Try it at the command line and find out :-)
For example ...
perl http://localhost/cgi-bin/somescript?a=b
will not work :-)
Why not just incorporate the code from the other script into the script
you're working on now? Or use LWP to access the other CGI script?
There's a few ways to do this :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
... [concerning quotation marks] even if we *did* quote anybody
in this business, it probably would be gibberish. -- Thom McLeod
------------------------------
Date: Sat, 13 Mar 2004 04:11:36 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: formmail problem
Message-Id: <pan.2004.03.13.09.11.35.402029@remove.adelphia.net>
On Fri, 12 Mar 2004 10:34:36 -0800, James wrote:
<snip>
> just in case you think those could be messing it up?
>
> thanks for any help
Use the CGI module instead of trying to 'roll your own' CGI parser.
http://search.cpan.org/~lds/CGI.pm-3.04/
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
I have learned To spell hors d'oeuvres Which still grates on
Some people's n'oeuvres. -- Warren Knox
------------------------------
Date: 12 Mar 2004 18:55:32 -0800
From: 6tc1@qlink.queensu.ca (Novice)
Subject: how to reset a variable
Message-Id: <b80e4a77.0403121855.118e291e@posting.google.com>
Hey all, I have a looping structure that contains some local scalar
variables in a Perl program of mine.
I don't think they are getting reinitialized each iteration of the
loop.
Code excerpt:
#------------------------
for ($iterator = 0; $iterator <= $#lines; $iterator++)
{
$line = @lines[$iterator];
$_ = $line;
$someScalarVar;
if (/^someTextImParsingOnANewLine/)
{
$someScalarVar = $line;
}
print $someScalarVar;
}
#------------------------
On some interations of the loop, the text
"someTextImParsingOnANewLine" is not found on a new line and
therefore, nothing is assigned to the scalar variable:
$someScalarVar
However, it seems to maintain its value from previous iterations of
the loop - is there a way to explicitly reset the value after each
iteration?
Thanks,
Novice
------------------------------
Date: 12 Mar 2004 22:21:12 -0500
From: Roland Roberts <roland@astrofoto.org>
Subject: Re: how to reset a variable
Message-Id: <m24qstmnyv.fsf@copernicus.rlent.pnet>
-----BEGIN xxx SIGNED MESSAGE-----
>>>>> "Novice" == Novice <6tc1@qlink.queensu.ca> writes:
Novice> Hey all, I have a looping structure that contains some local scalar
Novice> variables in a Perl program of mine.
Novice> I don't think they are getting reinitialized each iteration of the
Novice> loop.
Novice> Code excerpt:
Novice> #------------------------
Novice> for ($iterator = 0; $iterator <= $#lines; $iterator++)
Novice> {
Novice> $line = @lines[$iterator];
Novice> $_ = $line;
Novice> $someScalarVar;
Novice> if (/^someTextImParsingOnANewLine/)
Novice> {
Novice> $someScalarVar = $line;
Novice> }
Novice> print $someScalarVar;
Novice> }
Does
for ($iterator = 0; $iterator <= $#lines; $iterator++) {
my $line = @lines[$iterator];
my $someScalarVar;
if ($line =~ m/^someTextImParsingOnANewLine/) {
$someScalarVar = $line;
}
print $someScalarVar;
}
do what you want? Or do you need $someScalarVar to retain it's value
outside the loop? In the latter case, intead of "my $someScalarVar",
try "$someScalarVar = undef".
roland
- --
PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD RL Enterprises
roland@rlenter.com 6818 Madeline Court
roland@astrofoto.org Brooklyn, NY 11220
-----BEGIN xxx SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
Comment: Processed by Mailcrypt 3.5.4, an Emacs/PGP interface
iQCVAwUBQFJ+KOoW38lmvDvNAQGN4gQAlybAfv1c6VVjpcP7QzEZ13HoG+kq2x//
NnZYgKZ7DNWy/34uBYvqTkh2pAsopPYn1MpYogML3bnBlgxOxwjQ72xA5AEuov4n
bFE+aGmpfebwT2PR0cdUjuXaIKTW8nDV8VX8JojAPZ2t5+akiE92MfMOjYCceTzm
MMVb0HDWTQM=
=ucE0
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 13 Mar 2004 06:58:59 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: how to reset a variable
Message-Id: <4052afc0.99726344@news.erols.com>
6tc1@qlink.queensu.ca (Novice) wrote:
: Hey all, I have a looping structure that contains some local scalar
: variables in a Perl program of mine.
What makes them local? They're not declared anywhere.
: I don't think they are getting reinitialized each iteration of the
: loop.
Why would they?
: Code excerpt:
: #------------------------
: for ($iterator = 0; $iterator <= $#lines; $iterator++)
: {
: $line = @lines[$iterator];
: $_ = $line;
:
: $someScalarVar;
:
: if (/^someTextImParsingOnANewLine/)
: {
: $someScalarVar = $line;
: }
:
: print $someScalarVar;
: }
: #------------------------
:
: On some interations of the loop, the text
: "someTextImParsingOnANewLine" is not found on a new line and
: therefore, nothing is assigned to the scalar variable:
: $someScalarVar
:
: However, it seems to maintain its value from previous iterations of
: the loop - is there a way to explicitly reset the value after each
: iteration?
undef() it, of course.
Better that explicitly resetting it, implicitly reset it by declaring
it with my() so its scope is limited to the loop.
Better still, toss that dreadful code and do something like
print grep /^someTextImParsingOnANewLine/, @lines;
------------------------------
Date: Sat, 13 Mar 2004 11:09:50 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: how to reset a variable
Message-Id: <pan.2004.03.13.10.09.48.795273@aursand.no>
On Fri, 12 Mar 2004 18:55:32 -0800, Novice wrote:
> for ($iterator = 0; $iterator <= $#lines; $iterator++)
> {
> $line = @lines[$iterator];
> $_ = $line;
>
> $someScalarVar;
>
> if (/^someTextImParsingOnANewLine/)
> {
> $someScalarVar = $line;
> }
>
> print $someScalarVar;
> }
Uh. Way to C'ish. Try this instead;
foreach ( @lines ) {
if ( /^someTextImParsinOnANewLine/ ) {
print $_;
}
}
--
Tore Aursand <tore@aursand.no>
"Scientists are complaining that the new "Dinosaur" movie shows
dinosaurs with lemurs, who didn't evolve for another million years.
They're afraid the movie will give kids a mistaken impression. What
about the fact that the dinosaurs are singing and dancing?" -- Jay
Leno
------------------------------
Date: Sat, 13 Mar 2004 05:27:53 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: how to reset a variable
Message-Id: <pan.2004.03.13.10.27.51.231513@remove.adelphia.net>
On Fri, 12 Mar 2004 18:55:32 -0800, Novice wrote:
> Code excerpt:
> #------------------------
> for ($iterator = 0; $iterator <= $#lines; $iterator++)
> {
> $line = @lines[$iterator];
> $_ = $line;
>
> $someScalarVar;
>
> if (/^someTextImParsingOnANewLine/)
> {
> $someScalarVar = $line;
> }
>
> print $someScalarVar;
> }
> #------------------------
Is this what you *really* wanted to do (untested)?
foreach(@lines){
if(/^someTextImParsingOnANewLine/){
print "$_\n";
}
}
or maybe (untested) ....
open(FILE, 'some_file_name')
or die "open failed: $!\n";
while(<FILE>){
print "$_\n" if /^someTextImParsingOnANewLine/;
}
close FILE;
or even (untested) ....
foreach my $line(@lines){
print "$line\n" if /^someTextImParsingOnANewLine/;
}
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Thirty days hath Septober, April, June, and no wonder. all the rest have
peanut butter except my father who wears red suspenders."
------------------------------
Date: Sat, 13 Mar 2004 05:37:14 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: how to reset a variable
Message-Id: <pan.2004.03.13.10.37.11.481494@remove.adelphia.net>
On Sat, 13 Mar 2004 05:27:53 -0500, James Willmore wrote:
> On Fri, 12 Mar 2004 18:55:32 -0800, Novice wrote:
>
>> Code excerpt:
>> #------------------------
>> for ($iterator = 0; $iterator <= $#lines; $iterator++)
>> {
>> $line = @lines[$iterator];
>> $_ = $line;
>>
>> $someScalarVar;
>>
>> if (/^someTextImParsingOnANewLine/)
>> {
>> $someScalarVar = $line;
>> }
>>
>> print $someScalarVar;
>> }
>> #------------------------
>
> Is this what you *really* wanted to do (untested)?
>
> foreach(@lines){
>
> if(/^someTextImParsingOnANewLine/){
> print "$_\n";
> }
> }
>
> or maybe (untested) ....
>
> open(FILE, 'some_file_name')
> or die "open failed: $!\n";
>
> while(<FILE>){
> print "$_\n" if /^someTextImParsingOnANewLine/;
> }
>
> close FILE;
>
> or even (untested) ....
>
> foreach my $line(@lines){
> print "$line\n" if /^someTextImParsingOnANewLine/;
> }
>
> HTH
Remove the newlines (\n) and quotes :-(
Worked way too crazy hours this week 8-(
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Surprise your boss. Get to work on time.
------------------------------
Date: 12 Mar 2004 16:00:39 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: HTTP 1.1 module
Message-Id: <40524f27@news.victoria.tc.ca>
chatiman (chatiman@free.fr) wrote:
: Hello,
: I've started to write a HTTP 1.1 module in perl which supports pipelining.
: Will there be some interest to publish it ?
Client, server, or both?
There's always some interest.
How is this different than what LWP supplies, and if it does things that
LWP doesn't do, then why not provide it as some kind of patch to LWP?
------------------------------
Date: Sat, 13 Mar 2004 04:17:20 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: HTTP 1.1 module
Message-Id: <pan.2004.03.13.09.17.18.883314@remove.adelphia.net>
On Fri, 12 Mar 2004 11:39:09 +0100, chatiman wrote:
> I've started to write a HTTP 1.1 module in perl which supports pipelining.
> Will there be some interest to publish it ?
http://cpan.org/misc/cpan-faq.html
This will give you information on CPAN and releasing modules.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
A "No" uttered from deepest conviction is better and greater than
a "Yes" merely uttered to please, or what is worse, to avoid
trouble. -- Mahatma Ghandi
------------------------------
Date: Sat, 13 Mar 2004 10:59:42 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: HTTP 1.1 module
Message-Id: <4052db94$0$302$626a14ce@news.free.fr>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> a écrit dans le message de
news: 40524f27@news.victoria.tc.ca...
> Client, server, or both?
>
It's an HTTP client
> How is this different than what LWP supplies, and if it does things that
> LWP doesn't do, then why not provide it as some kind of patch to LWP?
>
LWP doesn't support persistent connections and pipelining.
LWPng (next generation) is a try to make it support boths but the last
release is from 1999 and it's in alpha state.
I started to write this module because it was fun to do and there was some
bugs
in LWPng that I couldn't fix.
------------------------------
Date: Sat, 13 Mar 2004 09:56:37 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Image-Magick.ppd installation
Message-Id: <40524137$0$22509$5a62ac22@freenews.iinet.net.au>
Hago Ziegler wrote:
> Hi,
>
> I have downloaded Image-Magick.zip. It contains Image-Magick.ppd, other
> files and a readme-file, which says:
> To install this ActiveState PPM package, run the following command
> in the current directory: ppm install Image-Magick.ppd
>
> I did this, but without success. This message is displayd:
>
> Error: no suitable installation target found for package Image-Magick.
>
> Does somebody know, what I could do?
>
> Perl is installed and works. (C:\perl)
> Also Image-Magick is installed and works.(C:\Image-Magick)
>
You'll get that error message if you try to install a binary built for
perl5.6 into perl5.8 (and vice versa).
ie. if you're running perl5.8 you need to find a ppm package built for
perl 5.8.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 13 Mar 2004 07:26:26 +0100
From: "Hago Ziegler" <ha@hago-ziegler.de>
Subject: Re: Image-Magick.ppd installation
Message-Id: <4052a9a5$0$7981$9b4e6d93@newsread2.arcor-online.net>
"Sisyphus" schrieb:
> > Error: no suitable installation target found for package
Image-Magick.
>
> You'll get that error message if you try to install a binary built for
> perl5.6 into perl5.8 (and vice versa).
>
> ie. if you're running perl5.8 you need to find a ppm package built for
> perl 5.8.
Thank you, good information.
Hago
------------------------------
Date: Fri, 12 Mar 2004 17:17:34 -0800
From: Dave Smith <dave@nowhere.com>
Subject: open(filehandle... is failing
Message-Id: <dave-1306A3.17173412032004@corp.supernews.com>
open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die ("cannot
email file");
This has worked great for a few years but today we migrated to a new
webserver and it does not work so great. If I execute the same line
myself it works fine, but not if executed from within perl. I tried
various other unix commands and they all fail also.
Dave
------------------------------
Date: Fri, 12 Mar 2004 17:38:16 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: open(filehandle... is failing
Message-Id: <8mot2c.gra.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-03-13, Dave Smith <dave@nowhere.com> wrote:
> open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die ("cannot
> email file");
It's unclear what you're trying to do; if you're opening a pipe to
qmail-inject, why are you also taking in $filename? You should probably
post a complete (but short) code snippet that puts the above code in
context.
Or use Net::SMTP or a similar module that is more portable than opening
a pipe.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAUmYHhVcNCxZ5ID8RAkdYAJ9qlqfUmlg4H3oL4YAehEjPykJdFQCfehk+
OIobxNAtHclkhhYNB/cuCpI=
=QQxB
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 13 Mar 2004 01:40:39 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: open(filehandle... is failing
Message-Id: <c2toog$8dn$1@news.simnet.is>
"Dave Smith" <dave@nowhere.com> wrote in message
news:dave-1306A3.17173412032004@corp.supernews.com...
> open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die ("cannot
> email file");
>
> This has worked great for a few years but today we migrated to a new
> webserver and it does not work so great.
what do you mean? did the die stop working ?
what is supposed to happen?
does $filename end in a '|' ?
> If I execute the same line
> myself it works fine, but not if executed from within perl.
what do you mean by executing the line yourself, without perl ?
when you say 'from within perl', do you mean 'in a cgi script' ?
> I tried
> various other unix commands and they all fail also.
did you use the same strange open() structure ?
please be more specific. give accurate and simple examples
of what you are talking about. the subject line suggests that
this fails:
open(F,'> /tmp/blah') or die "blah: $!";
print F "blah\n";
close F;
does it fail? if not you should select a more precise Subject.
gnari
------------------------------
Date: Sat, 13 Mar 2004 12:52:11 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: open(filehandle... is failing
Message-Id: <1915588.NqcyB3pKYZ@GMT-hosting-and-pickle-farming>
Dave Smith wrote:
> open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die ("cannot
> email file");
>
> This has worked great for a few years but today we migrated to a new
> webserver and it does not work so great. If I execute the same line
> myself it works fine, but not if executed from within perl. I tried
> various other unix commands and they all fail also.
>
> Dave
Using my crystal ball, the symptoms point to the web server running the cgi
as a differnt user (with different privileges) from when you execute the
command. Is the web server running as 'nobody', or 'apache'? Are you using
a cgi wrapper?
gtoomey
------------------------------
Date: Sat, 13 Mar 2004 12:57:23 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: open(filehandle... is failing
Message-Id: <1589189.5rBSmazWkP@GMT-hosting-and-pickle-farming>
Alternatives could be the cgi is in the wrong directory or has different
environment variables.
gtoomey
------------------------------
Date: Fri, 12 Mar 2004 22:03:42 -0800
From: Dave Smith <dave@nowhere.com>
Subject: Re: open(filehandle... is failing
Message-Id: <dave-269630.22034212032004@corp.supernews.com>
Thanks for all the replies. I can see I didn't post enough information
so I will try to be more complete.
I have a cgi script called convert2.cgi. If I run it from the command
line the output looks like this:
root@new-ba2 cgi-bin # ./convert2.cgi
CLIENTFILE="Y660003122004060109.txt" conversiontype="Payment File"
clientid="Y6600"
cannot email file at ./convert2.cgi line 201.
Here is the code at line 201:
open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die
("cannot email file");
close(MAIL);
I've tried various other unix commands and none of them work. I'm
stumped. We just moved from an old webserver to a newer webserver. Any
help would be appreciated.
Dave
ps. I added a "|" before the qmail command and now I'm not getting the
error. I'm not getting the email either, but I guess that's progress.
------------------------------
Date: Fri, 12 Mar 2004 22:42:58 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: open(filehandle... is failing
Message-Id: <ihau2c.tnb.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-03-13, Dave Smith <dave@nowhere.com> wrote:
> root@new-ba2 cgi-bin # ./convert2.cgi
> CLIENTFILE="Y660003122004060109.txt" conversiontype="Payment File"
> clientid="Y6600"
> cannot email file at ./convert2.cgi line 201.
>
> Here is the code at line 201:
> open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die
> ("cannot email file");
> close(MAIL);
>
> ps. I added a "|" before the qmail command and now I'm not getting the
> error. I'm not getting the email either, but I guess that's progress.
Okay, so you're trying to open a pipe on a filehandle, but then never
print anything to the filehandle or read anything from the filehandle.
So why are you using a filehandle? I'd suggest either using system() or
Net::SMTP or something similar. With system() you can read the return
value of qmail-inject, which may help figure out what's going wrong.
Your qmail logs may be helpful, as well (help for qmail you should
probably find elsewhere).
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAUq1vhVcNCxZ5ID8RAvfYAJ9dOEQOdTay3gBAi6JD9gO33LPCZQCdHs6y
kay6Vldz/XIhleBBqCZkASQ=
=4DdP
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 13 Mar 2004 05:32:33 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: open(filehandle... is failing
Message-Id: <pan.2004.03.13.10.32.26.530172@remove.adelphia.net>
On Fri, 12 Mar 2004 22:42:58 -0800, Keith Keller wrote:
> On 2004-03-13, Dave Smith <dave@nowhere.com> wrote:
>> root@new-ba2 cgi-bin # ./convert2.cgi
>> CLIENTFILE="Y660003122004060109.txt" conversiontype="Payment File"
>> clientid="Y6600"
>> cannot email file at ./convert2.cgi line 201.
>>
>> Here is the code at line 201:
>> open (MAIL, "/var/qmail/bin/qmail-inject < $filename") || die
>> ("cannot email file");
>> close(MAIL);
>>
>> ps. I added a "|" before the qmail command and now I'm not getting the
>> error. I'm not getting the email either, but I guess that's progress.
>
> Okay, so you're trying to open a pipe on a filehandle, but then never
> print anything to the filehandle or read anything from the filehandle.
> So why are you using a filehandle? I'd suggest either using system() or
> Net::SMTP or something similar. With system() you can read the return
> value of qmail-inject, which may help figure out what's going wrong.
> Your qmail logs may be helpful, as well (help for qmail you should
> probably find elsewhere).
Another fine reason to use an email module instead of the binary :-) The
script the OP is using would have remained unaffected if the OP opted to
use a Perl solution instead of one that depends upon a system binary that
is subject to such wonderful things as upgrades :-)
My $0.02 ...
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"I can't decide whether to commit suicide or go bowling." -- Florence
Henderson
------------------------------
Date: 12 Mar 2004 20:38:57 -0800
From: krishna@multimediastudio.com (Krishna Srinivasan)
Subject: Re: Perl module for analyzing log files
Message-Id: <361f42ca.0403122038.6864f0c9@posting.google.com>
> Depending on what you want to do, why not try Analog? It's not perl, but
> it does lots of reports, sumamries, graphs etc.
>
> P
I am actually trying to build my own log file analyzing engine for
some custom requirements. First I need to capture the log file in a
MySQL database. Currently I am using some complex split statements to
parse the log file. What is needed is (if possible) a more efficient
way to do this.
Krishna Srinivasan.
------------------------------
Date: Sat, 13 Mar 2004 10:58:36 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Perl module for analyzing log files
Message-Id: <pan.2004.03.13.09.58.17.367417@aursand.no>
On Fri, 12 Mar 2004 20:38:57 -0800, Krishna Srinivasan wrote:
>> Depending on what you want to do, why not try Analog? It's not perl,
>> but it does lots of reports, sumamries, graphs etc.
> I am actually trying to build my own log file analyzing engine for some
> custom requirements. First I need to capture the log file in a MySQL
> database. Currently I am using some complex split statements to parse
> the log file. What is needed is (if possible) a more efficient way to do
> this.
Your reason is valid enough, but there are _still_ modules on CPAN [1]
which will do this for you.
I you can't or don't want to use a module for this task, you should post
your existing code so that we can suggest improvements.
[1] <http://www.cpan.org/>
--
Tore Aursand <tore@aursand.no>
"Why shouldn't truth be stranger than fiction? Fiction, after all, has
to make sense." -- Mark Twain
------------------------------
Date: 12 Mar 2004 15:12:47 -0800
From: aclarke@austin.rr.com (ac)
Subject: Re: Regex to match simple line of XML
Message-Id: <ec432b9c.0403121512.3484b991@posting.google.com>
Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.03.12.18.17.26.789699@aursand.no>...
> On Fri, 12 Mar 2004 09:47:36 -0800, ac wrote:
> > I am trying to get a regex to match a simple line of XML.
>
> Why? What's wrong with the many XML modules?
Speed is critical here. You'll notice that I'm benchmarking against using
split, which is what my current implementation uses. I'm trying to figure
out the best case if I move my data representation over to XML (from CSV).
To stay with speed, I'm willing even to insist that for these XML files,
that the entire element be physically one a single line. So this is really
a subset of legal XML files and isn't really a problem because my application
controls both the reading and writing of these.
Allan
------------------------------
Date: Sat, 13 Mar 2004 00:43:45 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Regex to match simple line of XML
Message-Id: <40525704.77006825@news.erols.com>
aclarke@austin.rr.com (ac) wrote:
: Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.03.12.18.17.26.789699@aursand.no>...
: > On Fri, 12 Mar 2004 09:47:36 -0800, ac wrote:
: > > I am trying to get a regex to match a simple line of XML.
: >
: > Why? What's wrong with the many XML modules?
:
: Speed is critical here.
:
: You'll notice that I'm benchmarking against using
: split, which is what my current implementation uses.
Have you benchmarked against a real XML parser yet, or are you
prematurely optimizing?
: I'm trying to figure
: out the best case if I move my data representation over to XML (from CSV).
What was wrong with CSV that XML will cure?
: To stay with speed, I'm willing even to insist that for these XML files,
: that the entire element be physically one a single line. So this is really
: a subset of legal XML files and isn't really a problem because my application
: controls both the reading and writing of these.
If you have one Perl process talking to another through a file, why
bring XML into the picture? The Storable and Data::Dumper modules do
a jim dandy job of saving data in a format that can be quickly loaded.
------------------------------
Date: Sat, 13 Mar 2004 11:00:43 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Regex to match simple line of XML
Message-Id: <pan.2004.03.13.10.00.42.842492@aursand.no>
On Fri, 12 Mar 2004 15:12:47 -0800, ac wrote:
>>> I am trying to get a regex to match a simple line of XML.
>> Why? What's wrong with the many XML modules?
> Speed is critical here.
And your point is? The XML modules I've tried have been "fast enough".
What are you comparing against?
--
Tore Aursand <tore@aursand.no>
"A car is not the only thing that can be recalled by its maker." --
Unknown
------------------------------
Date: Sat, 13 Mar 2004 04:08:33 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: SCALAR(0x82e1024)
Message-Id: <pan.2004.03.13.09.08.32.40878@remove.adelphia.net>
On Fri, 12 Mar 2004 12:38:03 -0700, Todd Anderson wrote:
> Dear Persons,
> I have a flat file that is modified by user with a perl script from
> their browser. They can change password etc.. I keep getting this
> 'SCALAR(0x82e1024)' at the begiining of many rows in the flat file.
> Does anyone know what it might mean?
> Thanks in advance for your help.
Thanks for providing code which show what the issue is :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Xerox never comes up with anything original.
------------------------------
Date: Sat, 13 Mar 2004 11:01:43 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: SCALAR(0x82e1024)
Message-Id: <pan.2004.03.13.10.01.40.39187@aursand.no>
On Fri, 12 Mar 2004 12:38:03 -0700, Todd Anderson wrote:
> I have a flat file that is modified by user with a perl script from
> their browser. They can change password etc.. I keep getting this
> 'SCALAR(0x82e1024)' at the begiining of many rows in the flat file. Does
> anyone know what it might mean?
Yes. But are we able to help you? No, because you didn't post the
relevant code.
--
Tore Aursand <tore@aursand.no>
"Out of missiles. Out of bullets. Down to harsh language." -- Unknown
------------------------------
Date: Sat, 13 Mar 2004 00:09:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Text editor implemented in Perl
Message-Id: <t4f450dsaig036a483bi0jhtpufhlsvtal@4ax.com>
On Fri, 12 Mar 2004 11:30:14 +0000 (UTC), J Krugman
<jkrugman@yahbitoo.com> wrote:
>>Then I learned to use vim... the project's been on hold ever since :).
>
>What makes vim so much better than Emacs?
I can't say for sure but I think this, i.e. "vi(m) vs emacs", is by
far the principal flame raising topic around the world ever!
So how can it be worth asking? It's like politics: intelligent people
will impartially describe you pros and cons of one over the other, but
eventually they will tell you that their favourite one is the absolute
best and nothing in the world could make them change their mind!
BTW and on-(Perl)-topic: my editor, that is neither of the two cited
above, does a good job of automatic indenting and syntax highlighting,
but this does not work quite as seamlessly as e.g. with C, due to the
fact that "only perl can parse Perl" and to me the most annoying case
is that of an anonymous hashref being "mistaken for a block of code",
which is not surprising after all... now I wonder if either vim or
emacs can handle this situation better (at least in a subset of cases,
e.g. when the entries are specified as is usual by means of a "fat
comma"): does anybody know?
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Fri, 12 Mar 2004 23:49:54 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <c2tib1$akt$1@reader1.panix.com>
In <t4f450dsaig036a483bi0jhtpufhlsvtal@4ax.com> Michele Dondi <bik.mido@tiscalinet.it> writes:
>On Fri, 12 Mar 2004 11:30:14 +0000 (UTC), J Krugman
><jkrugman@yahbitoo.com> wrote:
>>>Then I learned to use vim... the project's been on hold ever since :).
>>
>>What makes vim so much better than Emacs?
>I can't say for sure but I think this, i.e. "vi(m) vs emacs", is by
>far the principal flame raising topic around the world ever!
>So how can it be worth asking?
Yeah, I admit it, I posed the question ineptly. I should have
phrased it "for those who switched from Emacs to vi(m), what led
you to do it?"
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
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 V10 Issue 6252
***************************************