[25192] in Perl-Users-Digest
Perl-Users Digest, Issue: 7440 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 23 14:05:47 2004
Date: Tue, 23 Nov 2004 11:05:08 -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 Tue, 23 Nov 2004 Volume: 10 Number: 7440
Today's topics:
ClearCase 05.00 using ClearCase::CtCmd::exec crash perl (Maverick Ieong)
Re: cookie failes <matthew.garrish@sympatico.ca>
Re: cookie failes <nospam@nospam.com>
Re: cookie failes <nospam@nospam.com>
Re: cookie failes (Anno Siegel)
Re: cookie failes <uri@stemsystems.com>
FAQ 4.41: How can I remove duplicate elements from a li <comdog@panix.com>
Re: File slurp takes a long time on some files <uri@stemsystems.com>
Re: File slurp takes a long time on some files <xx087@freenet.carleton.ca>
Re: File slurp takes a long time on some files (Tom Sliva)
Re: finding the number of keys in hash <uri@stemsystems.com>
Fork, exec - setsid? <rob@nova.hbx.us>
Re: Fork, exec - setsid? (Anno Siegel)
Re: Fork, exec - setsid? <rob@nova.hbx.us>
Re: Fork, exec - setsid? <do-not-use@invalid.net>
Re: Fork, exec - setsid? (Anno Siegel)
Re: How to print like debuggers `x $HASH` (Peter Scott)
Length of Array of Array of Array (Tom)
Re: Length of Array of Array of Array <perl@my-header.org>
Re: Length of Array of Array of Array <tadmc@augustmail.com>
Re: passing parameters from xsl to cgi script <tadmc@augustmail.com>
Re: passing parameters from xsl to cgi script <jwillmore@fastmail.us>
Re: passing parameters from xsl to cgi script <jurgenex@hotmail.com>
Re: passing parameters from xsl to cgi script <and11@rol.ru>
Re: redirect question <spamtrap@dot-app.org>
Re: redirect question <jurgenex@hotmail.com>
Re: redirect question <nospam@nospam.com>
Re: redirect question <nospam@nospam.com>
Re: redirect question <mritty@gmail.com>
Re: redirect question <flavell@ph.gla.ac.uk>
Re: sysread(socket..) problem on perl 5.8.0 linux <bcant@centra-systems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Nov 2004 08:53:24 -0800
From: mluvw47@gmail.com (Maverick Ieong)
Subject: ClearCase 05.00 using ClearCase::CtCmd::exec crash perl 5.8.3
Message-Id: <d4b6522b.0411230853.3bda4bf3@posting.google.com>
Hi,
I have perl (5.8.3), and the ClearCase verison (From Help About),
Rational Clearcase Explorer 2002.05.00+, Copyright 1990,2004 Rational
Software Co-operation. Running the following script will a dialog
"Perl Command Line Interpreter, For information about this error,
click here"
When I click on the link:
Error signature AppName perl.exe AppVer: 5.8.3.809 ModName:
libatriaks.dll
ModVer:0.0.0.0 Offset:0001b478
#This is a simple list vobs script
use strict;
use warnings;
use ClearCase::CtCmd;
my @test;
@test = ClearCase::CtCmd::exec("lsvob");
print @test;
Anybody encouter this problem?
I have a machine running the same perl, the ClearCase verison show
Rational Clearcase Explorer 2002.05.00+, Copyright 1990,2003 Rational
Software Co-operation.(note the copyright date show 2003) Running the
above script no problem. Is that some kind of patch have installed?
How can I tell? If so, is that a way to backout the patch?
TIA,
Mav
------------------------------
Date: Tue, 23 Nov 2004 09:22:55 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: cookie failes
Message-Id: <1JHod.28839$Le1.599779@news20.bellglobal.com>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1101209667.172064@nntp.acecape.com...
>
> "MrReallyVeryNice"
> <MrReallyVeryNice.REMOVE.NO.SPAM@Yahoo.REMOVE.NO.SPAM.com> wrote in
> message
> news:xeWdnXeTXZFILD_cRVn-sQ@comcast.com...
>
>
>> When I execute the script from my browser (Firefox 1.0), it displays:
>> 'foo' is set to bar.
>> You should hopefully see the same results from your browser. :)
>>
>> I hope that this is helpful.
>> MrRVN
>
> got it.....i missed the part that it is ONLY written to the file if it is
> persistent....i assumed as long as the browser stayed open, it would
> appear
> within the cookie file
>
No kidding? And someone pays you to program for the Web?
Matt
------------------------------
Date: Tue, 23 Nov 2004 12:08:22 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: cookie failes
Message-Id: <1101229780.480383@nntp.acecape.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:1JHod.28839$Le1.599779@news20.bellglobal.com...
> No kidding? And someone pays you to program for the Web?
and what do people pay your mother to do?
------------------------------
Date: Tue, 23 Nov 2004 12:12:37 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: cookie failes
Message-Id: <1101230035.57901@nntp.acecape.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:1JHod.28839$Le1.599779@news20.bellglobal.com...
> No kidding? And someone pays you to program for the Web?
>
actually no, am a C'bie....totally new to the Web....so as i said before,
what are your mother's rates?
------------------------------
Date: 23 Nov 2004 17:56:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: cookie failes
Message-Id: <cnvtkm$1vi$2@mamenchi.zrz.TU-Berlin.DE>
daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
> news:1JHod.28839$Le1.599779@news20.bellglobal.com...
> > No kidding? And someone pays you to program for the Web?
> >
> actually no, am a C'bie....
Yeah, right.
> totally new to the Web....so as i said before,
> what are your mother's rates?
So when someone doubts your capabilities you insult their mother. That's
very convincing.
Anno
------------------------------
Date: Tue, 23 Nov 2004 18:16:50 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: cookie failes
Message-Id: <x7653wmnvy.fsf@mail.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
>> totally new to the Web....so as i said before,
>> what are your mother's rates?
AS> So when someone doubts your capabilities you insult their mother.
AS> That's very convincing.
wait until someone doubts his mother's coding skills!
<watching kaplan learn perl and web is like watching a train wreck in
slow motion. i amazed how slowly he picks up stuff, at his poor doc
parsing skills and at his vaunted claim to know c so well.>
and even though i have been guilty of this, i hate typos in subject
lines!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 23 Nov 2004 17:03:08 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.41: How can I remove duplicate elements from a list or array?
Message-Id: <cnvqgb$ps0$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
4.41: How can I remove duplicate elements from a list or array?
There are several possible ways, depending on whether the array is
ordered and whether you wish to preserve the ordering.
a) If @in is sorted, and you want @out to be sorted: (this assumes all
true values in the array)
$prev = "not equal to $in[0]";
@out = grep($_ ne $prev && ($prev = $_, 1), @in);
This is nice in that it doesn't use much extra memory, simulating
uniq(1)'s behavior of removing only adjacent duplicates. The ", 1"
guarantees that the expression is true (so that grep picks it up)
even if the $_ is 0, "", or undef.
b) If you don't know whether @in is sorted:
undef %saw;
@out = grep(!$saw{$_}++, @in);
c) Like (b), but @in contains only small integers:
@out = grep(!$saw[$_]++, @in);
d) A way to do (b) without any loops or greps:
undef %saw;
@saw{@in} = ();
@out = sort keys %saw; # remove sort if undesired
e) Like (d), but @in contains only small positive integers:
undef @ary;
@ary[@in] = @in;
@out = grep {defined} @ary;
But perhaps you should have been using a hash all along, eh?
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Tue, 23 Nov 2004 15:55:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: File slurp takes a long time on some files
Message-Id: <x7brdoo904.fsf@mail.sysarch.com>
>>>>> "JS" == Joe Smith <joe@inwap.com> writes:
JS> Tom Sliva wrote:
>> I have two text files I am trying to slurp.
JS> Have you tried using File::Slurp instead of a do-it-yourself solution?
JS> It is specifically optimized for certain cases.
ahem!! s/certain/all/
:-)
but the OP's problem sounds more like an OS/box issue than
software. such big differences in slurp time mean something else is
wrong. slurping a couple of megs or K's of lines should not take so
long.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 23 Nov 2004 16:46:53 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: File slurp takes a long time on some files
Message-Id: <slrncq6qbt.m87.xx087@smeagol.ncf.ca>
At 2004-11-22 08:43PM, Tom Sliva <hosehead2k1@hotmail.com> wrote:
> I am using ActiveState Perl 5.6.1 on Win2k with 512Meg RAM. I have
> two text files I am trying to slurp. File A is ~2.2M and 35k lines
> and File B is ~1M and 43k lines (lines are shorter). I have two of
[...]
> Type A files open and dump in ~1 second. Type B files take ~5 seconds
> for the 1st file and ~77 seconds for the second. Additionally if I
[...]
Are some of your files on a network drive, or are they all local?
--
Glenn Jackman
------------------------------
Date: 23 Nov 2004 10:12:26 -0800
From: hosehead2k1@hotmail.com (Tom Sliva)
Subject: Re: File slurp takes a long time on some files
Message-Id: <6af01096.0411231012.6f32e87@posting.google.com>
Uri Guttman <uri@stemsystems.com> wrote in message news:<x7brdoo904.fsf@mail.sysarch.com>...
> JS> Have you tried using File::Slurp instead of a do-it-yourself solution?
> JS> It is specifically optimized for certain cases.
>
> ahem!! s/certain/all/
>
> :-)
>
I was afraid it would be an OS issue, but File::Slurp did the trick.
I can now read all 4 files in about 2-3 seconds no matter what
combination. Thanks for everyone's help and thanks to Uri for writing
this package
------------------------------
Date: Tue, 23 Nov 2004 15:51:55 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: finding the number of keys in hash
Message-Id: <x7ekiko961.fsf@mail.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> Alan Mead <amead@comcast.net> wrote in comp.lang.perl.misc:
>> Here's what you want, I think.. but why?
>>
>> for (my $i=0; $i< scalar keys %$A; $i++) { print "$i\n"; }
AS> ^^^^^^
AS> No need for "scalar", since "<" puts its arguments in scalar context.
AS> A bit shorter is
AS> for my $i ( 0 .. keys %$A ) { ... }
off by one error
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 23 Nov 2004 15:25:43 +0100
From: Robert Manea <rob@nova.hbx.us>
Subject: Fork, exec - setsid?
Message-Id: <79hvnc.7p.ln@rob.unisolblade.de>
Hello everyone,
I'm trying to solve a quite simply looking job but can't really come up
with an elegant working solution.
The why:
--------
I wrote a frontend to a DVB (digital video broadcasting) card in
Gtk2 using Perl. So I came up with the need to fork some processes away
and execute a couple of external programs via 'exec()'; these programs
are linked together via pipes.
The DVB-card is built in a remote machine so I first have to fork away a
new process and do:
exec('ssh remote-machine start-the-dvb-stuff-and-multicast-it')
after that fork away another process and:
exec('grab-the-stream | demultiplex-it | videoplayer').
The problem:
------------
As exec normally never returns and spwans a shell when it finds any
metachars in the command to be executed there is no means to get the PID
of those or the spawned shell.
But unfortunatelly I have to quit those processes every time the user
wants to switch channels via the parent.
The question:
-------------
How do I kill the forked away programms without knowing their PID?
Or better, how to kill them based on their SID?
What I tried:
-------------
(the commands where replaced by some simpler ones to make testing
easier)
#v+
#!/usr/bin/perl
#
use strict;
use warnings;
use POSIX;
$SIG{'CHLD'} = \&reaper;
sub reaper {
$SIG{'CHLD'} = \&reaper;
#my $kid = waitpid(-1, WNOHANG);
my $kid = wait();
}
my $command='tail -f foo|grep grep';
my $cpid = fork();
if ( $cpid == 0) {
print "Child starting\n";
my $s_id = POSIX::setsid(); # Put the stuff into an own session
exec $command;
} elsif ($cpid < 0) {
warn "Cannot fork: $!";
}
sleep 5; # Actually the parent runs forever
kill 9, $cpid;
sleep 5;
return ;
__END__
#v-
This doesn't seem to work as the 'exec()'ed commands exist further on
after killing the child process.
The work around:
----------------
Simply remember the 'exec()'ed command names and do a
system('pkill -9 grab-the-stream') and so on..
This looks more than ugly and I'm sure there are way nicer methods.
Greets & TIA, Rob
--
The Enterprise meets God, and it's a child, a computer, or a C program.
------------------------------
Date: 23 Nov 2004 15:02:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Fork, exec - setsid?
Message-Id: <cnvje4$lg1$2@mamenchi.zrz.TU-Berlin.DE>
Robert Manea <rob@nova.hbx.us> wrote in comp.lang.perl.misc:
> Hello everyone,
>
> I'm trying to solve a quite simply looking job but can't really come up
> with an elegant working solution.
>
>
> The why:
> --------
>
> I wrote a frontend to a DVB (digital video broadcasting) card in
> Gtk2 using Perl. So I came up with the need to fork some processes away
> and execute a couple of external programs via 'exec()'; these programs
> are linked together via pipes.
>
> The DVB-card is built in a remote machine so I first have to fork away a
> new process and do:
>
> exec('ssh remote-machine start-the-dvb-stuff-and-multicast-it')
>
> after that fork away another process and:
>
> exec('grab-the-stream | demultiplex-it | videoplayer').
>
>
> The problem:
> ------------
>
> As exec normally never returns and spwans a shell when it finds any
> metachars in the command to be executed there is no means to get the PID
> of those or the spawned shell.
The shell will have the pid that fork() returned to the parent.
> But unfortunatelly I have to quit those processes every time the user
> wants to switch channels via the parent.
>
>
> The question:
> -------------
>
> How do I kill the forked away programms without knowing their PID?
> Or better, how to kill them based on their SID?
Kill the shell that runs the pipeline. You have the pid.
Anno
------------------------------
Date: Tue, 23 Nov 2004 16:13:26 +0100
From: Robert Manea <rob@nova.hbx.us>
Subject: Re: Fork, exec - setsid?
Message-Id: <m2kvnc.g21.ln@rob.unisolblade.de>
Segfault in module "Anno Siegel" - dump details are as follows:
> Robert Manea <rob@nova.hbx.us> wrote in comp.lang.perl.misc:
>> The question:
>> -------------
>>
>> How do I kill the forked away programms without knowing their PID?
>> Or better, how to kill them based on their SID?
> Kill the shell that runs the pipeline. You have the pid.
Unfortunatelly this won't do the job. After killing the shell (in other
words the PID returned by 'fork()') the programms in the pipeline still
exist and are up and running.
This strategy was what I tried first..
> Anno
Greets, Rob
--
The Enterprise meets God, and it's a child, a computer, or a C program.
------------------------------
Date: 23 Nov 2004 16:34:17 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Fork, exec - setsid?
Message-Id: <yzd1xek8tqe.fsf@invalid.net>
Robert Manea <rob@nova.hbx.us> writes:
> #!/usr/bin/perl
> #
> use strict;
> use warnings;
> use POSIX;
>
> $SIG{'CHLD'} = \&reaper;
>
> sub reaper {
> $SIG{'CHLD'} = \&reaper;
> #my $kid = waitpid(-1, WNOHANG);
> my $kid = wait();
> }
>
> my $command='tail -f foo|grep grep';
>
> my $cpid = fork();
> if ( $cpid == 0) {
> print "Child starting\n";
> my $s_id = POSIX::setsid(); # Put the stuff into an own session
> exec $command;
> } elsif ($cpid < 0) {
> warn "Cannot fork: $!";
> }
>
> sleep 5; # Actually the parent runs forever
>
> kill 9, $cpid;
>
> sleep 5;
> return ;
>
> __END__
> #v-
>
> This doesn't seem to work as the 'exec()'ed commands exist further on
> after killing the child process.
'kill' can take a negative number, and then kills the processes in a
process group. This may be what you want. Thus:
kill 9, -$cpid;
Another solution is to send $s_id up to the parent by some means.
------------------------------
Date: 23 Nov 2004 17:44:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Fork, exec - setsid?
Message-Id: <cnvst0$1vi$1@mamenchi.zrz.TU-Berlin.DE>
Robert Manea <rob@nova.hbx.us> wrote in comp.lang.perl.misc:
> Segfault in module "Anno Siegel" - dump details are as follows:
>
> > Robert Manea <rob@nova.hbx.us> wrote in comp.lang.perl.misc:
> >> The question:
> >> -------------
> >>
> >> How do I kill the forked away programms without knowing their PID?
> >> Or better, how to kill them based on their SID?
>
> > Kill the shell that runs the pipeline. You have the pid.
>
>
> Unfortunatelly this won't do the job. After killing the shell (in other
> words the PID returned by 'fork()') the programms in the pipeline still
> exist and are up and running.
>
> This strategy was what I tried first..
That would mean that one or another of the programs you start has
demon-like properties and puts itself in the background (It may leave
a pidfile around, if so).
The whole thing has little to do with Perl, but is a fork/exec/kill
issue and also depends on the behavior of the programs you run. The
question to ask is, how would you end a run if the program was used
"normally", whatever that means, and see how to gain that kind of
control from Perl.
Anno
------------------------------
Date: Tue, 23 Nov 2004 15:34:33 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: How to print like debuggers `x $HASH`
Message-Id: <dMIod.313102$nl.190816@pd7tw3no>
In article <30875970.0411221555.76246052@posting.google.com>,
ipellew@pipemedia.co.uk (Ian Pellew) writes:
>Hi All;
>
>What is the call to print a HASH like the debugs print of a hash:-
>
>EG:-
>$t_xmlin = eval{XMLin($xml, forcearray=>0, NormaliseSpace=>2)};
>
>DB<2> x $t_xmlin
>0 HASH(0x22a84a8)
> 'define' => HASH(0x22a840c)
> 'gen_dir' => 'c:/Program Files/Apache Group/Apache2/cgi-bin/Pages/Generated/'
> 'src_dir' => 'c:/Program Files/Apache Group/Apache2/cgi-bin/Pages/'
>Etc.
>
>This a lot easier than the Dumper output.
I don't think you'll find many people agreeing with that, but if
you feel you must go down this path:
% perl -e 'require "dumpvar.pl"; dumpValue([{answer => 42}], -1)'
0 HASH(0x476a4)
'answer' => 42
Ugh.
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: 23 Nov 2004 09:13:10 -0800
From: sudhirx@gmail.com (Tom)
Subject: Length of Array of Array of Array
Message-Id: <f50c52fa.0411230913.5f20d521@posting.google.com>
How to find the length of an "Array of Array of Array"
I get syntax error when i say $#fx[0][0][0]
------------------------------
Date: Tue, 23 Nov 2004 18:29:33 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: Length of Array of Array of Array
Message-Id: <kks6q0dd0jfsumji5a9e5eht9c3adkps8p@4ax.com>
X-Ftn-To: Tom
sudhirx@gmail.com (Tom) wrote:
>How to find the length of an "Array of Array of Array"
>
>I get syntax error when i say $#fx[0][0][0]
This should give you the latest index from third level array,
$#{ $fx[0][0] }
--
Matija
------------------------------
Date: Tue, 23 Nov 2004 11:39:15 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Length of Array of Array of Array
Message-Id: <slrncq6te3.2c4.tadmc@magna.augustmail.com>
Tom <sudhirx@gmail.com> wrote:
> How to find the length of an "Array of Array of Array"
>
> I get syntax error when i say $#fx[0][0][0]
Well first off, the $#array syntax does NOT give you the length
of the array, it gives you the last index in the array.
The @array syntax in a scalar context gives you the length of the array.
To find the length of your multi-dim array, simply apply "Use Rule 1" from:
perldoc perlreftut
I usually do it in 3 steps:
my $length = @array; # pretend it is a regular old array
my $length = @{ }; # replace the _name_ of the array with a block
my $length = @{ $fx[0][0][0] }; # fill in the block with code that
# returns a reference to the
# right kind of thingy
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Nov 2004 07:17:50 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: passing parameters from xsl to cgi script
Message-Id: <slrncq6e3u.ab.tadmc@magna.augustmail.com>
lievemario <lievemario@hotmail.com> wrote:
> I've done something like
^^^^^^^^^^^^^^
That is not good enough for us to be able to help you.
Show us something "exactly like" what you've done, and we
can help you fix it.
> How can I solve this?
You have not communicated to us what, exactly, the "this" is.
Post a short and complete program *that we can run* that illustrates
your problem, and we will help solve your problem.
Have you seen the Posting Guidelines that are posted here frequently?
use PSI::ESP; # cutsie talk for a wild-ass guess at what the problem is
perldoc -q variable
How can I expand variables in text strings?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Nov 2004 10:43:57 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: passing parameters from xsl to cgi script
Message-Id: <pan.2004.11.23.15.43.55.925031@fastmail.us>
On Tue, 23 Nov 2004 12:11:32 +0100, lievemario wrote:
> I have made a perl script witch gets information out of a database,
> transfers it into an xml-file file and than I parse this to a html document
> using xsl.
> The problem is dat the html doc needs a parameter which can be found in the
> xml file.
> I've done something like
> <xsl:variable name="id" select="person_id"/>
> <a href="http://localhost/CGI/detailsselection.cgi?ID=$id"><xsl:value-of
> select="name"></xsl:value-of><xsl:value-of
> select="first_name"></xsl:value-of></a>
>
> Of course this doesn't give me the value of the id-variable. But it just
> returns $id.
> How can I solve this?
Maybe you meant to post this to comp.text.xml? This is more an issue with
the XSLT you wrote than it is Perl.
HTH
Jim
------------------------------
Date: Tue, 23 Nov 2004 16:24:12 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: passing parameters from xsl to cgi script
Message-Id: <MuJod.2152$TG2.138@trnddc01>
lievemario wrote:
> I have made a perl script witch gets information out of a database,
> transfers it into an xml-file file and than I parse this to a html
> document using xsl.
> The problem is dat the html doc needs a parameter which can be found
> in the xml file.
> I've done something like
> <xsl:variable name="id" select="person_id"/>
> <a
> href="http://localhost/CGI/detailsselection.cgi?ID=$id"><xsl:value-of
> select="name"></xsl:value-of><xsl:value-of
> select="first_name"></xsl:value-of></a>
>
> Of course this doesn't give me the value of the id-variable. But it
> just returns $id.
> How can I solve this?
Please show us _exactly_ how you would like the generated XSL to look like
and we can tell you how to create it from your Perl program.
Would be good to have the relevant excerpt of your program as a
self-contained, executable test program such that we can find and pinpoint
the actual problem.
With the little factual information you gave us it's all just reading tea
leafes and crystal balls.
jue
------------------------------
Date: Tue, 23 Nov 2004 21:01:56 +0000
From: Andrew Tkachenko <and11@rol.ru>
Subject: Re: passing parameters from xsl to cgi script
Message-Id: <cnvu31$3l$1@news.rol.ru>
lievemario wrote on 23 ŠŠ¾ŃбŃŃ 2004 11:11:
> I have made a perl script witch gets information out of a database,
> transfers it into an xml-file file and than I parse this to a html
document
> using xsl.
> The problem is dat the html doc needs a parameter which can be found in
the
> xml file.
> I've done something like
> <xsl:variable name="id" select="person_id"/>
> <a
href="http://localhost/CGI/detailsselection.cgi?ID=$id"><xsl:value-of
> select="name"></xsl:value-of><xsl:value-of
> select="first_name"></xsl:value-of></a>
>
> Of course this doesn't give me the value of the id-variable. But it just
> returns $id.
> How can I solve this?
>
> Thanks
>
> L
I guess this should work (I did'nt test it):
<xsl:variable name="id" select="person_id"/>
<xsl:element name="a">
<xsl:attribute name="href">http://localhost/CGI/detailsselection.cgi?ID=
<xsl:value-of select="$id"/>
</xsl:attribute>
<xsl:value-of select="name"/><xsl:value-of
select="first_name"/>
</xsl:element>
--
Andrew
------------------------------
Date: Tue, 23 Nov 2004 09:31:52 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: redirect question
Message-Id: <1tSdnQCosOZ81D7cRVn-qg@adelphia.com>
daniel kaplan wrote:
> but according to my documentation "the redirect header has to be printed
> before anything else is emmited from the CGI script.
Not sure what documentation you're referring to here, but that's an
over-simplification. If it's a beginner-level tutorial, that might be
deliberate, to avoid confusing newbies.
In more general terms, HTTP headers have to precede content; getting
that wrong will produce a "500 Server Error".
But both cookies and redirects are HTTP headers; I don't know whether
the order matters. Offhand, I don't think it does. In Richard's example,
the cookie is simply passed to the redirect() function, and that
function arranges the HTTP headers as it sees fit.
> so i replaced the redirect with the META refresh statement.....and of course
> that works. but since i fail to find a reference to it in the FAQ
You might find a reference to <meta ...> elements in the FAQ for an HTML
group or a CGI group, but this is a Perl group.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Tue, 23 Nov 2004 16:29:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: redirect question
Message-Id: <pzJod.2153$TG2.84@trnddc01>
daniel kaplan wrote:
> i can do a redirect OR i can set a cookie, but it appears that i
> cannot do BOTH on the same page.
Why are you asking in a Perl NG?
Those who know about cookies and redirects and such things are over across
the street at e.g. comp.infosystems.www.authoring.cgi and other places with
CGI or Web or HTML in the name.
Or are you also asking your Ford dealer how to fix a leaking faucet just
because your plumber is driving a Ford pickup?
jue
------------------------------
Date: Tue, 23 Nov 2004 12:10:18 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: redirect question
Message-Id: <1101229896.27577@nntp.acecape.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:pzJod.2153$TG2.84@trnddc01...
>
> Why are you asking in a Perl NG?
well cause i am doing all this via Perl...Perl commands...so i thought it
sort of overlaps.....
------------------------------
Date: Tue, 23 Nov 2004 12:11:35 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: redirect question
Message-Id: <1101229973.458224@nntp.acecape.com>
"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:1tSdnQCosOZ81D7cRVn-qg@adelphia.com...
> daniel kaplan wrote:
>
> You might find a reference to <meta ...> elements in the FAQ for an HTML
> group or a CGI group, but this is a Perl group.
again, since it's all done via Perl i thought it was an overlap, will find a
CGI group instead,,,,thanks
------------------------------
Date: Tue, 23 Nov 2004 18:34:24 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: redirect question
Message-Id: <QoLod.6281$Gw.3815@trndny09>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1101229896.27577@nntp.acecape.com...
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:pzJod.2153$TG2.84@trnddc01...
> >
> > Why are you asking in a Perl NG?
>
> well cause i am doing all this via Perl...Perl commands...so i thought
it
> sort of overlaps.....
Perl is simply the language you were using to print HTTP header strings.
When partitioning your problem to determine "is it CGI or is it Perl",
ask yourself if your question would change at all if you were using C++
instead of Perl. In this case, you would still need to know exactly how
to format the HTTP header, regardless of whether you use
print "Location: http://example.com\n";
or
cout << "Location: http://example.com" << endl;
Since the choice of language is not relevant to the problem, your
question does not pertain to the language of choice.
Paul Lalli
------------------------------
Date: Tue, 23 Nov 2004 18:47:15 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: redirect question
Message-Id: <Pine.LNX.4.61.0411231839110.21104@ppepc56.ph.gla.ac.uk>
On Tue, 23 Nov 2004, Sherm Pendley wrote:
> But both cookies and redirects are HTTP headers; I don't know
> whether the order matters.
Inevitably, I'm going to have to step in briefly here to point out
that what a CGI script emits is a CGI response (documented in the CGI
specification), rather than an HTTP response per se (documented in the
HTTP specification, RFC2616).
In the case of the parsed-headers type of CGI script, it's the job of
the server to accept the CGI response headers, and use them to compose
a properly-formed HTTP response to the client. The similarity of many
(but not all) CGI response headers to HTTP response headers is
deliberate, but can be confusing. See also Perl FAQ part 9 on this
topic.
To the actual (off-topic) question: certainly it's feasible to send a
cookie and redirect in the same transaction: in fact it's a popular
technique amongst cookie merchants. However, there are rules about
cookie domains, and clients might also apply their own more-stringent
rules (e.g ignoring cross-domain cookies). So there are plenty of
ways of getting the request wrong (none of which have anything to do
with the Perl programming language, so it's high time for me to stop
there).
------------------------------
Date: Tue, 23 Nov 2004 17:24:28 +0000 (UTC)
From: "Bean" <bcant@centra-systems.com>
Subject: Re: sysread(socket..) problem on perl 5.8.0 linux
Message-Id: <cnvroc$snu$1@sparta.btinternet.com>
After more coffee I realized i've mixed buffered/non-buffered IO :/
Ben.
"Bean" <bcant@centra-systems.com> wrote in message
news:cnvd2c$sr9$1@hercules.btinternet.com...
> Hi,
>
> I've been debugging a socket read problem using perl 5.8.0 on RH8.0. The
> following script fails consistantly on perl 5.8.0 but works fine on 5.8.3
> and 5.8.5. It also works if either side (client or server) is _not_
> running on 5.8.0.
>
> The problem is that the client sysread returns 0 (eof) when the server has
> sent data. I've strace'd both sides and the server thinks it has sent 1024
> bytes but the client receives nothing and sysread returns 0, strace
> reports ESPIPE on the socket fd.
>
> Am I doing something wrong in the code? Could it be a perl bug or maybe a
> hardware problem? My different versions of perl are all on different
> machines.
>
> Can any one help?
>
> Regards, Ben.
>
> Output:
>
> $ ./sfile.pl server
> sent header FILE:2082:1024
> server wrote a block 1024 in size
> server wrote a block 1024 in size
> server wrote a block 34 in size
> write total size = 2082
>
> $ ./sfile.pl client
> read header FILE:2082:1024
> trying to reading 1024
> sysread returned 0
> read total size = 0
>
> Script:
>
> #!/usr/bin/perl
> # -*- perl -*-
> use strict;
> use warnings;
> use IO::Socket::INET;
> use IO::File;
>
> $|=1;
>
> server() if $ARGV[0] eq 'server';
> client() if $ARGV[0] eq 'client';
>
> sub server
> {
> my $s = IO::Socket::INET->new
> (
> LocalPort => 9999,
> Listen => 1,
> Proto => 'tcp',
> Type => SOCK_STREAM,
> ReuseAddr => 1,
> ) || die $!;
>
> $s->autoflush(1);
> $s->blocking(1);
>
> while (1)
> {
> my $n = $s->accept;
> write_file($n,$0);
> $n->close;
> }
> }
>
>
> sub client
> {
> my $s = IO::Socket::INET->new
> (
> PeerAddr => 'localhost',
> PeerPort => 9999,
> Proto => 'tcp',
> Type => SOCK_STREAM,
> ) || die $!;
>
> $s->autoflush(1);
> $s->blocking(1);
>
> read_file($s);
>
> $s->close;
> }
>
> sub write_file
> {
> my $s = shift;
> my $f = shift;
>
> die unless -f $f;
> my $fh = IO::File->new("<$f") || die $!;
>
> my $bs = 1024;
> my $sz = (stat($f))[7];
> my $ts = 0; # total size written
>
> if ( $sz < $bs )
> {
> $bs = $sz;
> }
>
> my $head = "FILE:$sz:$bs\n";
> die "header write failed" if syswrite($s,$head,length($head)) !=
> length($head);
> print "sent header $head";
>
>
> while ( $bs )
> {
> my $buf = '';
> my $wr = sysread($fh,$buf,$bs) || die "reading $bs from file: $!";
> $ts += $wr;
>
> my $sw = syswrite($s,$buf,$wr);
> print "short write!" if ( $sw != $wr );
>
> print "server wrote a block $sw in size\n";
>
> if ( ( $sz - $ts ) < $bs )
> {
> $bs = $sz - $ts;
> }
> }
> print "write total size = $ts\n";
> }
>
> sub read_file
> {
> my $s = shift;
> my $head = $s->getline || die "header read failed";
> print "read header $head";
>
> my ($ts, $bs);
> if ( $head =~ /FILE\:(\d+)\:(\d+)\n/ )
> {
> ($ts, $bs) = ($1,$2);
> }
> else
> {
> die "incorrect header format";
> }
>
> my $tr = 0; # total size read
> while ($bs)
> {
> if ( ( $ts - $tr ) < $bs )
> {
> $bs = $ts - $tr;
> }
>
> print "trying to reading $bs\n";
> my $buf = '';
> my $rd = sysread($s,$buf,$bs);
> if ( $rd > 0 )
> {
> $tr += $rd;
> }
> else
> {
> print "sysread returned $rd\n";
> last;
> }
>
> }
> print "read total size = $tr\n";
>
>
> }
>
> My perl is:
>
> Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
> Platform:
> osname=linux, osvers=2.4.18-11smp, archname=i386-linux-thread-multi
> uname='linux daffy.perf.redhat.com 2.4.18-11smp #1 smp thu aug 15
> 06:41:59 edt 2002 i686 i686 i386 gnulinux '
> config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dmyhostname=localhost
> -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat,
> Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr
> -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles
> -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog
> -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly
> -Dpager=/usr/bin/less -isr'
> hint=recommended, useposix=true, d_sigaction=define
> usethreads=define use5005threads=undef useithreads=define
> usemultiplicity=define
> useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
> use64bitint=undef use64bitall=undef uselongdouble=undef
> usemymalloc=n, bincompat5005=undef
> Compiler:
> cc='gcc', ccflags
> ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
> -I/usr/include/gdbm',
> optimize='-O2 -march=i386 -mcpu=i686',
> cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/include/gdbm'
> ccversion='', gccversion='3.2 20020822 (Red Hat Linux Rawhide 3.2-5)',
> gccosandvers=''
> intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
> ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
> lseeksize=8
> alignbytes=4, prototype=define
> Linker and Libraries:
> ld='gcc', ldflags =' -L/usr/local/lib'
> libpth=/usr/local/lib /lib /usr/lib
> libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
> perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
> libc=/lib/libc-2.2.92.so, so=so, useshrplib=true, libperl=libperl.so
> gnulibc_version='2.2.92'
> Dynamic Linking:
> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
> ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
> cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
>
>
> Characteristics of this binary (from libperl):
> Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
> PERL_IMPLICIT_CONTEXT
> Built under linux
> Compiled at Sep 1 2002 23:56:49
> @INC:
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0
> /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0
> /usr/lib/perl5/vendor_perl
> .
>
>
------------------------------
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 7440
***************************************