[23450] in Perl-Users-Digest
Perl-Users Digest, Issue: 5665 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 15 18:05:41 2003
Date: Wed, 15 Oct 2003 15:05:10 -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 Wed, 15 Oct 2003 Volume: 10 Number: 5665
Today's topics:
5.8.0 h2xs seems broken wrt. library arguments <clint@0lsen.net>
Re: Converting indented data to a tree <tore@aursand.no>
Re: Converting indented data to a tree <skuo@mtwhitney.nsc.com>
Re: How can i write the values of a form through a cgi <some@one.com>
How Do I Use Proxy in Net:HTTP? <ir@labranche.com>
Re: How Do I Use Proxy in Net:HTTP? <HelgiBriem_1@hotmail.com>
Re: How does one move down a line in a file? (Roy Johnson)
Is flock Needed for Logs? <ir@labranche.com>
Re: Is flock Needed for Logs? <ir@labranche.com>
Re: Is flock Needed for Logs? (Jay Tilton)
mod_perl and 5.8.1 <jboes@qtm.net>
Perl in Legato AAM (catfish_face)
Re: Perl scripts for Unix on my windows machine (Ren Patterson)
Re: Perl scripts for Unix on my windows machine <michael.p.broida@boeing_oops.com>
Re: Perl scripts for Unix on my windows machine (Tad McClellan)
Re: Perl scripts for Unix on my windows machine <noreply@gunnar.cc>
Re: Perl scripts for Unix on my windows machine (Tad McClellan)
Re: Perl scripts for Unix on my windows machine (Tad McClellan)
Re: Perl scripts for Unix on my windows machine <emschwar@pobox.com>
PPM 'upgrade' command broken? <NOSPAM@NOSPAM.COM>
Re: string substitution problem <No_4@dsl.pipex.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Oct 2003 20:15:50 GMT
From: Clint Olsen <clint@0lsen.net>
Subject: 5.8.0 h2xs seems broken wrt. library arguments
Message-Id: <slrnboranm.46f.clint@poly.0lsen.net>
Hi:
The docpage for h2xs states that any extra library arguments required
(libraries and such) should follow any headerfile arguments. However, when
I do this h2xs complains that -L and -l arguments are "unknown".
Thanks,
-Clint
------------------------------
Date: Wed, 15 Oct 2003 20:32:26 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Converting indented data to a tree
Message-Id: <pan.2003.10.15.17.03.43.866641@aursand.no>
On Wed, 15 Oct 2003 07:45:19 +0000, Anno Siegel wrote:
>> @array = (
>> [1,0], # Page 1
>> [2,1], # Page 1.1
>> [3,2], # Page 1.1.1
>> [4,2], # Page 1.1.2
>> [5,1], # Page 1.2
>> [6,1], # Page 1.3
>> [7,0], # Page 2
>> [8,7], # Page 2.1
>> );
> I thought I did, until I sw the last item. Should "[8,7]" be "[8,1]"?
> Also, the first component seems to be nothing but a counter, one more
> than the index. What is it for?
*trying to figure out what's Anno is thinking* Ah! No, no. Guess I
should have explained it a little better.
The "innermost" array is a [id, parent_id] thing. While the 'id' can be a
simple counter (incremental), I need to keep track of the relationship to
the parent also.
While writing this message I got the idea of push'ing and pop'ing the
current parent '$count' onto/from an array, and it _seems to_ work;
my @array = ();
my $this_level = 0;
my $prev_level = 0;
my @parents = (0);
my $count = 0;
while ( <DATA> ) {
chomp;
next unless ( length );
$count++;
my ( $spaces ) = m,^( *),;
$this_level = length( $spaces ) / 4;
if ( $this_level > $prev_level ) {
push( @parents, $count );
}
elsif ( $this_level < $prev_level ) {
pop( @parents );
}
push( @array, [$count, $parents[-1]] );
$prev_level = $this_level;
}
Anyone for a better solution?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Wed, 15 Oct 2003 12:07:17 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Converting indented data to a tree
Message-Id: <Pine.GSO.4.21.0310151204160.415-100000@mtwhitney.nsc.com>
On Wed, 15 Oct 2003, Tore Aursand wrote:
> On Wed, 15 Oct 2003 07:45:19 +0000, Anno Siegel wrote:
> >> @array = (
> >> [1,0], # Page 1
> >> [2,1], # Page 1.1
> >> [3,2], # Page 1.1.1
> >> [4,2], # Page 1.1.2
> >> [5,1], # Page 1.2
> >> [6,1], # Page 1.3
> >> [7,0], # Page 2
> >> [8,7], # Page 2.1
> >> );
>
> > I thought I did, until I sw the last item. Should "[8,7]" be "[8,1]"?
> > Also, the first component seems to be nothing but a counter, one more
> > than the index. What is it for?
>
> *trying to figure out what's Anno is thinking* Ah! No, no. Guess I
> should have explained it a little better.
>
> The "innermost" array is a [id, parent_id] thing. While the 'id' can be a
> simple counter (incremental), I need to keep track of the relationship to
> the parent also.
(snipped)
Perhaps something like:
use Data::Dumper;
my %parent;
my @array;
while (<DATA>) {
chomp;
my $leading_spaces = 0;
++$leading_spaces while (/\G /g);
$leading_spaces /= 4;
if ($leading_spaces) {
push @array, [ $., $parent{$leading_spaces-1}];
} else {
push @array, [$., 0];
}
$parent{$leading_spaces} = $.;
}
print Dumper(\@array);
__DATA__
Page 1
Page 1.1
Page 1.1.1
Page 1.1.2
Page 1.2
Page 1.3
Page 2
Page 2.1
--
Hope this helps,
Steven
------------------------------
Date: Wed, 15 Oct 2003 19:02:06 GMT
From: Anand <some@one.com>
Subject: Re: How can i write the values of a form through a cgi script in a txt file.
Message-Id: <OQgjb.2136$8x2.1333352@newssrv26.news.prodigy.com>
In your cgi script names 'script.cgi' you can get values of parameter
passed. You have to write values to file in this script.
Let me know if you need some more input.
--Anand
JR wrote:
> How can i write the values of a form through a cgi script in a txt file.
>
> My html pages is for example:
>
> <FORM METHOD=POST ACTION="script.cgi">
> <input type="text" name="nummer" size="20"></p>
> <p><input type="text" name="paswoord" size="20"></p>
> <p><input type="submit" value="Submit" name="Send">
> </form>
>
> Can anybody help me with this simple script
> I am a newbie and i would love to learn perl/cgi.
>
>
> Thanks
------------------------------
Date: Wed, 15 Oct 2003 18:26:03 GMT
From: "Public Interest" <ir@labranche.com>
Subject: How Do I Use Proxy in Net:HTTP?
Message-Id: <%igjb.180135$0v4.13826349@bgtnsc04-news.ops.worldnet.att.net>
Can anyone tell me how the proxy is implemented in LWP:UserAgent? I have to
use a proxy in Net:HTTP, but proxy is not supported in it.
------------------------------
Date: Wed, 15 Oct 2003 19:07:43 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: How Do I Use Proxy in Net:HTTP?
Message-Id: <9e6rovcaubkqstrljd2jf3favvh7p44rs8@4ax.com>
On Wed, 15 Oct 2003 18:26:03 GMT, "Public Interest" <ir@labranche.com>
wrote:
>Can anyone tell me how the proxy is implemented in LWP:UserAgent?
>I have to use a proxy in Net:HTTP, but proxy is not supported in it.
$ua->proxy(['http'] => "http://$proxy:$port");
------------------------------
Date: 15 Oct 2003 14:07:46 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: How does one move down a line in a file?
Message-Id: <3ee08638.0310151307.48f60bf3@posting.google.com>
James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031015125342.67fce71f.jwillmore@remove.adelphia.net>...
> --untested--
> my($first,$second,$third);
> while(<FILE>){
> $first = <FILE>;
You're still getting the first line into $_, for no apparent reason.
You might consider
until(eof FILE)
instead of
while(<FILE>)
> $second = <FILE>;
> $third = <FILE>;
> last;
Or, since you're breaking out of the loop on the first pass, just
don't have a loop.
> my $count = 1;
> while(<FILE>){
> $first = <FILE> if $count == 1;
> $second = <FILE> if $count == 2;
> $third = <FILE> if $count == 3;
> last if $count == 4;
> }
> --untested--
You need to increment $count each time, or you're going to repeatedly
assign $_ and $first, and none of the others. Is it not possible for
you to test the solutions you propose?
> --untested--
> my @lines = <FILE>;
> #access each ine as an element of the array
> --untested--
That's a winner, at least.
------------------------------
Date: Wed, 15 Oct 2003 20:44:35 GMT
From: "Public Interest" <ir@labranche.com>
Subject: Is flock Needed for Logs?
Message-Id: <Tkijb.2686$Ec1.230079@bgtnsc05-news.ops.worldnet.att.net>
I want to run a banner exchange. Click-through exchange. So far, my script
works fine in testing. I am not using flock in the file now. I am worried
about if 2 people hit the same cgi the same time. I think 2 cgis will be
started and try to write to the same log file. What will happen? Will the
second one hold and wait for the first done with the log file?
open (my $out1, ">>log.txt");
open (my $out2, ">>log.txt");
print $out1 1;
print $out2 2;
close $out1;
close $out2;
here is from perldoc -f flock:
Two potentially non-obvious but traditional "flock" semantics
are that it waits indefinitely until the lock is granted, and
that its locks merely advisory. Such discretionary locks are
more flexible, but offer fewer guarantees. This means that files
locked with "flock" may be modified by programs that do not also
use "flock". See perlport, your port's specific documentation,
or your system-specific local manpages for details. It's best to
assume traditional behavior if you're writing portable programs.
What if the first process is taking long time to finish or it is totally
crashed? Will the file be unlocked automatically after certain time? I am
worried using flock lose my log file totally.
------------------------------
Date: Wed, 15 Oct 2003 20:49:58 GMT
From: "Public Interest" <ir@labranche.com>
Subject: Re: Is flock Needed for Logs?
Message-Id: <Wpijb.2691$Ec1.230087@bgtnsc05-news.ops.worldnet.att.net>
One very interesting test:
open (my $out1, ">>log.txt");
open (my $out2, ">>log.txt");
print $out2 2;
print $out1 1;
close $out1;
close $out2;
Guess what the result is? Nothing is crashed. Perl can take care of the
flock itself automatically. At least it is on Win32 system. Unlike what many
think, it is no 21, but 12. Perl will like the first opener to finish the
job before leting the second starts. Isn't that GREAT? No flock is ever
needed now... haha
------------------------------
Date: Wed, 15 Oct 2003 21:32:57 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Is flock Needed for Logs?
Message-Id: <3f8db38c.295026941@news.erols.com>
"Public Interest" <ir@labranche.com> wrote:
: One very interesting test:
: open (my $out1, ">>log.txt");
: open (my $out2, ">>log.txt");
: print $out2 2;
: print $out1 1;
: close $out1;
: close $out2;
:
: Guess what the result is? Nothing is crashed. Perl can take care of the
: flock itself automatically. At least it is on Win32 system. Unlike what many
: think, it is no 21, but 12.
: Perl will like the first opener to finish the
: job before leting the second starts.
That's a bold conclusion (reckless, even) to draw from a single test.
See what happens when you swap the order of the close() statements.
Do you still believe that the first filehandle opened gets predence?
The circumstances where simultaneous file access will cause problems
occur rarely, and writing two measly characters is unlikely to coincide
with those circumstances. Try this test instead:
#!perl
use warnings;
use strict;
unlink 'log.txt';
open (my $out1, ">>log.txt") or die $!;
open (my $out2, ">>log.txt") or die $!;
my $now = time;
my $count;
until( time > $now+10 ) {
$count++;
print $out1 "out1: $count\n";
print $out2 "out2: $count\n";
}
close $out1;
close $out2;
That's more likely to corrupt the log file like,
out1: 18930
out1: 18931
ou8639
out2: 18640
out2: 18641
And that's just one process with two filehandles. There could be dozens
of those processes at once in a CGI environment.
: Isn't that GREAT? No flock is ever
: needed now... haha
Haha indeed.
------------------------------
Date: Wed, 15 Oct 2003 21:04:10 GMT
From: Jeff Boes <jboes@qtm.net>
Subject: mod_perl and 5.8.1
Message-Id: <17161fe4f9a06c6b9b2d33a5d1201218@news.teranews.com>
Does anyone here know if there are issues between mod_perl (V1.26, if I'm
reading my info right) and Perl V5.8.1? When we upgraded Perl and rebuilt
mod_perl, our webserver scripts stopped producing output. They run, and if they
open files they produce output in the files, but nothing to the browser.
I'm wondering if this has anything to do with the PerlIO change ...
------------------------------
Date: 15 Oct 2003 11:22:44 -0700
From: john_hosie@hotmail.com (catfish_face)
Subject: Perl in Legato AAM
Message-Id: <c6c3280b.0310151022.10621bfc@posting.google.com>
Legato AAM has a built-in Perl interpreter for processing rules,
triggers, etc. Does anyone know of anyplace where samples are for Perl
scripts that might be used with Legato AAM? I'm really trying to see
if there is some repository in the sky for this sort of stuff.
------------------------------
Date: 15 Oct 2003 11:21:18 -0700
From: reneap@hotmail.com (Ren Patterson)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <2e13d330.0310151021.5d189738@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bmjgbl$o5j7j$1@ID-> Mike?
Nice to meet you
>
> Please read the posting guidelines for this group:
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
Thank you, maybe next time an ignorant person (let us not use the N
word "newbie" oh my!) comes to the group that person can be directed
to your group etiquette instead of critizing her/him for not following
your little social code.
>
> >> What happened when you tried it?
> >
> > I have not tried yet, I wanted to know before hand if I would be
> > wasting my time for maybe there was no way they worked.
>
> Really? So you preferred to waste the time of hundreds of readers of
> this group??
It is analogous to a webmaster wanting to make a webpage available for
wireless devices. This webmaster does not know WAP which would be read
by non-html wireless devices. However, the webmaster searched
indefinitely and finds not an answer. Webmaster does not set up the
page "yet" to try it on a wireless device for the webmaster suspects
there might be an incompatibility. So one good day the webmaster heads
down to where the "know it all gods of WAP" hang out and asks them a
simple question as to whether it can be done or not.
So mike
If just telling someone wether a cgi-perl script is known to work or
not in a certain OS, is considered a waste of time by those who know -
then maybe those who know should not even be allowed to post on a
forum that should help those who don't...
------------------------------
Date: Wed, 15 Oct 2003 18:19:17 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <3F8D8FA5.8F3030FF@boeing_oops.com>
James Willmore wrote:
>
> The first line of your script _may_ present an issue. Consider this:
> #!/usr/bin/perl -w
>
> This is no /usr/bin on many Windows boxes (unless you're using Cygwin,
> which it appears you're not).
I've had that line in many of my Windows Perl scripts and
had NO problems with it. Windows doesn't use that line
in any way at all, so it's just another comment line.
From my MINIMAL experience shifting Perl between Unix and
Windows, I think the biggest problems are:
1) Unix NEEDS that initial line shown above (usually). When moving
from Windows to Unix, you need to make sure it's added.
When going from Unix to Windows, leave it there: no problem.
2) Executing external commands (as someone else pointed out)
may need tinkering to get the correct command names/etc
for the target system.
3) File path syntax has to be changed. Windows wants drive
letters; Unix uses "/" and mountpoints. I don't know
if it's possible for Perl to seamlessly handle both in
one script.
4) I'm sure there are other problems, but I haven't had any pop
up in the very few 'ports I've done.
Mike
------------------------------
Date: Wed, 15 Oct 2003 09:21:52 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <slrnboqm00.7ei.tadmc@magna.augustmail.com>
Ren Patterson <reneap@hotmail.com> wrote:
>> If you really mean that, then please start quoting your
>> followups properly.
>
> What are you talking about?
Who is "you"?
[ Please provide an attribution when you quote someone. ]
I am talking about the conventions that are near universal in
Usenet newsgroups.
http://www.catb.org/~esr/faqs/smart-questions.html
> quoting your followups properly?
http://web.presby.edu/~nnqadmin/nnq/nquote.html
> what is
> wrong with this guy mike?
Who is Mike?
Since there is no Mike in this thread, I'm wondering which guy is
really the guy that has something wrong?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Oct 2003 21:07:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <bmk5vk$ngmu4$1@ID-184292.news.uni-berlin.de>
Ren Patterson wrote:
> Gunnar Hjalmarsson wrote:
>> Ren Patterson wrote:
>>> Tad McClellan wrote:
>>>> Ren Patterson wrote:
>>>>> Does that mean they should be able to run from my Windows
>>>>> web server cgi-bin folder?
>>>>
>>>> What happened when you tried it?
>>>
>>> I have not tried yet, I wanted to know before hand if I would
>>> be wasting my time for maybe there was no way they worked.
>>
>> Really? So you preferred to waste the time of hundreds of readers
>> of this group??
<snip>
> So mike
Mike?
> If just telling someone wether a cgi-perl script is known to work
> or not in a certain OS, is considered a waste of time by those who
> know - then maybe those who know should not even be allowed to post
> on a forum that should help those who don't...
My point is that your way of justifying that you hadn't tried revealed
an irritating lack of respect to those whose help you were seeking.
As regards your initial general question, you got some general
guidance. It's of course not possible for anybody to know whether your
particualar programs, which we know nothing about, can be run on Windows.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 15 Oct 2003 15:23:32 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <slrnborb64.7ss.tadmc@magna.augustmail.com>
Michael P. Broida <michael.p.broida@boeing_oops.com> wrote:
> James Willmore wrote:
>>
>> The first line of your script _may_ present an issue. Consider this:
>> #!/usr/bin/perl -w
>>
>> This is no /usr/bin on many Windows boxes (unless you're using Cygwin,
>> which it appears you're not).
>
> I've had that line in many of my Windows Perl scripts and
> had NO problems with it. Windows doesn't use that line
> in any way at all, so it's just another comment line.
Windows doesn't use it, but perl _does_, so it isn't really
just another comment line.
perl parses that line looking for switches, such as -w
> 3) File path syntax has to be changed. Windows wants drive
> letters; Unix uses "/" and mountpoints. I don't know
Windows can use "/" as the directory separator too.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Oct 2003 15:35:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <slrnborbs7.7ss.tadmc@magna.augustmail.com>
Ren Patterson <reneap@hotmail.com> wrote:
> So mike
Who _is_ this Mike?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Oct 2003 15:35:44 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Perl scripts for Unix on my windows machine
Message-Id: <etozng2w5e7.fsf@wormtongue.fc.hp.com>
tadmc@augustmail.com (Tad McClellan) writes:
> Ren Patterson <reneap@hotmail.com> wrote:
>
>> So mike
>
> Who _is_ this Mike?
<URL:http://www.itswalky.com/faq/biomike.html> maybe, but it's still
not obvious if it's meant as a compliment or not.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 15 Oct 2003 21:53:32 GMT
From: "Eric McDaniel" <NOSPAM@NOSPAM.COM>
Subject: PPM 'upgrade' command broken?
Message-Id: <qljjb.780961$Ho3.207414@sccrnsc03>
Installation: Win32 ActivePerl 5.8.0.806
I'm not sure when this started happening, but...
ppm> upgrade
...
Email-MIME-Encodings 1.0: up to date.
File-BaseDir 0.02: up to date.
File-MimeInfo 0.6: new version 0.7 available in ActiveState PPM2 Repository
IO-stringy 2.108: up to date.
Image-IPTCInfo 1.7: up to date.
...
Ok, I see File-MimeInfo could use updating:
ppm> upgrade -install File-MimeInfo
File-MimeInfo 0.6: new version 0.7 available in ActiveState PPM2 Repository
And that's it. No upgrading actually occurs. I've tried all of the upgrade
options (-force, -follow, etc); the result is always the same.
I have to resort to uninstall and reinstall. I've done this for a few
packages and it works fine, so why not upgrade? I am doing this from an
administrative account.
Any ideas?
Thanks.
-Eric
------------------------------
Date: Wed, 15 Oct 2003 19:14:31 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: string substitution problem
Message-Id: <3f8d8e87$0$6626$cc9e4d1f@news.dial.pipex.com>
Jeff 'japhy' Pinyan wrote:
> The other problem you'll encounter is that Perl interpolates $2 when you
> make that string you pass to system(). You don't want Perl to do that;
> you want Perl to send the literal string '$2' to the system() command so
> that when system() runs perl, perl sees $2.
>
> system("perl -pi -e 's{foo(/\\w+)+(/\\w+)}bar\$2}' file");
>
Also, Perl will (or may) pass that through a shell. If you don't
want to deal with ensuring things aren't interpreted by the shell as
well, then pas system a LIST of arguments, rather than a single string.
--
-*- Just because I've written it here doesn't -*-
-*- mean that you should, or I do, believe it. -*-
------------------------------
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 5665
***************************************