[29547] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 791 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 24 14:09:43 2007

Date: Fri, 24 Aug 2007 11:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 24 Aug 2007     Volume: 11 Number: 791

Today's topics:
        dynamic regex <braindumped@expires-31-08-2007.news-group.org>
    Re: dynamic regex <mritty@gmail.com>
    Re: dynamic regex <papahuhn@gmx.net>
    Re: dynamic regex <mritty@gmail.com>
    Re: dynamic regex <glennj@ncf.ca>
    Re: dynamic regex <glennj@ncf.ca>
    Re: dynamic regex <glennj@ncf.ca>
    Re: How safe is $0? xhoster@gmail.com
    Re: How safe is $0? <bik.mido@tiscalinet.it>
    Re: How safe is $0? (Gary E. Ansok)
    Re: Is there a better way of doing this? <jgibson@mail.arc.nasa.gov>
    Re: ISO: What is the "best practice" for getting error  <lvirden@gmail.com>
    Re: ISO: What is the "best practice" for getting error  xhoster@gmail.com
    Re: ISO: What is the "best practice" for getting error  xhoster@gmail.com
        push into hashs of arrays <jiehuang001@gmail.com>
    Re: Regular expression use <lvirden@gmail.com>
    Re: Regular expression use <byte8bits@gmail.com>
    Re: Starting with SOAP <perl4hire@softouch.on.ca>
    Re: Threaded Perl Processes Going to Sleep Simultaneous xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 24 Aug 2007 17:24:22 +0200
From: Thomas Peter <braindumped@expires-31-08-2007.news-group.org>
Subject: dynamic regex
Message-Id: <1187969062.03@user.newsoffice.de>

hi,
i want to parametrize the usage of the search and the replacement of 
s/search/replace/

the following code:

use Getopt::Long;
GetOptions("p=s" => \$args{pattern}, "r=s" => \$args{replacement});
print s/$args{pattern}/$args{replacement}/;

(yes i could achieve that with perl -p -e but that's only a small 
snippet from a bigger context)

when i call the thing with -p '.*(\d+).*' and -r '\1'
it only prints \1 not the first occurence of \d+

any suggestions what's wrong?

thanx and have a nice weekend!
thomas



------------------------------

Date: Fri, 24 Aug 2007 09:37:08 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: dynamic regex
Message-Id: <1187973428.448893.173850@i13g2000prf.googlegroups.com>

On Aug 24, 11:24 am, Thomas Peter <braindum...@expires-31-08-2007.news-
group.org> wrote:
> hi,
> i want to parametrize the usage of the search and the replacement of
> s/search/replace/
>
> the following code:
>
> use Getopt::Long;
> GetOptions("p=s" => \$args{pattern}, "r=s" => \$args{replacement});
> print s/$args{pattern}/$args{replacement}/;

You know that s/// does not return the modified string, right?  You're
printing the number of substitutions that will be made (which will be
either 0 or 1, since you didn't use the /g modifier)

>
> (yes i could achieve that with perl -p -e but that's only a small
> snippet from a bigger context)
>
> when i call the thing with -p '.*(\d+).*' and -r '\1'
> it only prints \1 not the first occurence of \d+
>
> any suggestions what's wrong?

You need to eval your replacement, twice.  change s/search/replace/ to
s/search/replace/ee

Paul Lalli



------------------------------

Date: Fri, 24 Aug 2007 18:56:28 +0200
From: papahuhn <papahuhn@gmx.net>
Subject: Re: dynamic regex
Message-Id: <5j8gttF3s2tn2U1@mid.dfncis.de>

Paul Lalli schrieb:
> On Aug 24, 11:24 am, Thomas Peter <braindum...@expires-31-08-2007.news-
>> when i call the thing with -p '.*(\d+).*' and -r '\1'
>> it only prints \1 not the first occurence of \d+
>> any suggestions what's wrong?
> 
> You need to eval your replacement, twice.  change s/search/replace/ to
> s/search/replace/ee
> 
> Paul Lalli



Besides,\1 is only valid in the matching part of an s///. Probably you 
need $1.


------------------------------

Date: Fri, 24 Aug 2007 10:01:49 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: dynamic regex
Message-Id: <1187974909.987940.291910@i13g2000prf.googlegroups.com>

On Aug 24, 12:56 pm, papahuhn <papah...@gmx.net> wrote:
> Paul Lalli schrieb:
>
> > On Aug 24, 11:24 am, Thomas Peter <braindum...@expires-31-08-2007.news-
> >> when i call the thing with -p '.*(\d+).*' and -r '\1'
> >> it only prints \1 not the first occurence of \d+
> >> any suggestions what's wrong?

> Besides,\1 is only valid in the matching part of an s///.
> Probably you need $1.

It's perfectly *valid*.  It's just not recommended:

$ perl -wle'
$s = "foo bar";
$s =~ s/(foo)/\1BAR/;
print $s;
'
\1 better written as $1 at -e line 3.
fooBAR bar

Paul Lalli




------------------------------

Date: 24 Aug 2007 17:08:35 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: dynamic regex
Message-Id: <slrnfcu44k.egu.glennj@smeagol.ncf.ca>

At 2007-08-24 12:37PM, "Paul Lalli" wrote:
>  On Aug 24, 11:24 am, Thomas Peter <braindum...@expires-31-08-2007.news-
>  group.org> wrote:
> > i want to parametrize the usage of the search and the replacement of
> > s/search/replace/
> >
> > the following code:
> >
> > use Getopt::Long;
> > GetOptions("p=s" => \$args{pattern}, "r=s" => \$args{replacement});
> > print s/$args{pattern}/$args{replacement}/;
[...]
> > when i call the thing with -p '.*(\d+).*' and -r '\1'
> > it only prints \1 not the first occurence of \d+
>  
>  You need to eval your replacement, twice.  change s/search/replace/ to
>  s/search/replace/ee

And you want to use '$1', not '\1', in the replacement part.  \1 is only
used within a regular expression.

Also note that in /.*(\d+).*/ the first ".*" is greedy, so you'll only
get the *last* digit.  Try /.*?(\d+).*/

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


------------------------------

Date: 24 Aug 2007 17:16:52 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: dynamic regex
Message-Id: <slrnfcu4k5.egu.glennj@smeagol.ncf.ca>

At 2007-08-24 01:01PM, "Paul Lalli" wrote:
>  On Aug 24, 12:56 pm, papahuhn <papah...@gmx.net> wrote:
> > Paul Lalli schrieb:
> >
> > > On Aug 24, 11:24 am, Thomas Peter <braindum...@expires-31-08-2007.news-
> > >> when i call the thing with -p '.*(\d+).*' and -r '\1'
> > >> it only prints \1 not the first occurence of \d+
> > >> any suggestions what's wrong?
>  
> > Besides,\1 is only valid in the matching part of an s///.
> > Probably you need $1.
>  
>  It's perfectly *valid*.  It's just not recommended:
>  
>  $ perl -wle'
>  $s = "foo bar";
>  $s =~ s/(foo)/\1BAR/;
>  print $s;
>  '
>  \1 better written as $1 at -e line 3.
>  fooBAR bar

Is this why it's not recommended?

$ perl -le '$_="abc1234def";print;$rep=q{\1};s/.*?(\d+).*/$rep/ee;print'
abc1234def
SCALAR(0x124c74)

$ perl -le '$_="abc1234def";print;$rep=q{$1};s/.*?(\d+).*/$rep/ee;print'
abc1234def
1234

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


------------------------------

Date: 24 Aug 2007 17:17:49 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: dynamic regex
Message-Id: <slrnfcu4lu.egu.glennj@smeagol.ncf.ca>

At 2007-08-24 01:16PM, "Glenn Jackman" wrote:
>  At 2007-08-24 01:01PM, "Paul Lalli" wrote:
> >  On Aug 24, 12:56 pm, papahuhn <papah...@gmx.net> wrote:
> > > Besides,\1 is only valid in the matching part of an s///.
> > > Probably you need $1.
> >  
> >  It's perfectly *valid*.  It's just not recommended:
> >  
> >  $ perl -wle'
> >  $s = "foo bar";
> >  $s =~ s/(foo)/\1BAR/;
> >  print $s;
> >  '
> >  \1 better written as $1 at -e line 3.
> >  fooBAR bar
>  
>  Is this why it's not recommended?
>  
>  $ perl -le '$_="abc1234def";print;$rep=q{\1};s/.*?(\d+).*/$rep/ee;print'
>  abc1234def
>  SCALAR(0x124c74)
>  
>  $ perl -le '$_="abc1234def";print;$rep=q{$1};s/.*?(\d+).*/$rep/ee;print'
>  abc1234def
>  1234

btw, that's perl v5.6.1



-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


------------------------------

Date: 24 Aug 2007 16:05:38 GMT
From: xhoster@gmail.com
Subject: Re: How safe is $0?
Message-Id: <20070824120539.794$C4@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On 24 Aug 2007 14:49:10 GMT, xhoster@gmail.com wrote:
>
> >Why not just put "my $orig_0=$0" near the top of the script?  Then
> >you don't have to worry about either Perl's internals or other modules
> >changing it, plus it frees you (or your successor) to change the real $0
> >in the future if you ever feel the need to use its status-indicating
> >feature.
>
> Huh?!? "near the top"? As Anno correctly pointed out, to be really
> sure it needs to be in a BEGIN block before other BEGIN blocks and
> use's.

Sure, if you are afraid someone will assign to $0 during compilation.
That seems even less likely than assigning to it during run-time.  But
better safe than sorry, I guess.

my $orig_0; BEGIN {$orig_0=$0};

It would be nice if there was some way to "my" something but causing
it to get defined in the lexical scope one level up (or, one level "out" I
suppose, rather than up).


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 24 Aug 2007 19:00:25 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How safe is $0?
Message-Id: <8b3uc3ddqqdr94c0s7uci8cika20ga0e9v@4ax.com>

On 24 Aug 2007 16:05:38 GMT, xhoster@gmail.com wrote:

>Michele Dondi <bik.mido@tiscalinet.it> wrote:
>> On 24 Aug 2007 14:49:10 GMT, xhoster@gmail.com wrote:
>>
>> >Why not just put "my $orig_0=$0" near the top of the script?  Then
>> >you don't have to worry about either Perl's internals or other modules

^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^^^

>> >changing it, plus it frees you (or your successor) to change the real $0
>> >in the future if you ever feel the need to use its status-indicating
>> >feature.
>>
>> Huh?!? "near the top"? As Anno correctly pointed out, to be really
>> sure it needs to be in a BEGIN block before other BEGIN blocks and
>> use's.
>
>Sure, if you are afraid someone will assign to $0 during compilation.
>That seems even less likely than assigning to it during run-time.  But
>better safe than sorry, I guess.

Since you wrote "or other modules", it was just to be precise.

>my $orig_0; BEGIN {$orig_0=$0};
>
>It would be nice if there was some way to "my" something but causing
>it to get defined in the lexical scope one level up (or, one level "out" I
>suppose, rather than up).

I *thought* that Perl 6's OUTER:: namespace could serve this purpose,
but this doesn't seem to be the case, at least as of the pugs I have
(this is not a definitive proof):

pugs> {my $OUTER::foo=10}
Internal error while running expression:
***
    Unexpected "::foo"
    expecting word character, "?", "!", trait, "=", infix assignment,
term postf
ix, operator or "}"
    at <interactive> line 1, column 11
pugs> my $foo; {$OUTER::foo=10}
10
pugs> say $foo;
10


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Fri, 24 Aug 2007 17:28:29 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: How safe is $0?
Message-Id: <fan4ft$2ea$1@naig.caltech.edu>

In article <1187949633.488453.272370@q3g2000prf.googlegroups.com>,
Bill H  <bill@ts1000.us> wrote:
>If I use $0 to determine the name of the script that is running is it
>safe to assume that it will not change within the script (as long as I
>never intentionally try to change it? The way I am using it is setting
>certain messages based on the the script. Somthing like this:
>
>if ($0 eq "foo.pl")
>{
>$blah = "foo";
>}
>if ($0 eq "bar.pl")
>{
>$blah = "bar";
>}

Not directly related to your question, but bear in mind that it is not
specified whether $0 will be just the script name, or might contain
directory path information.  In my experience, Unix-based systems usually
have $0 containing whatever was entered by the user (just "foo.pl" if the
script was found through $PATH, or the path entered by the user), and
Windows has $0 contain a full path to the script.  So you might want
to use basename() (from File::Basename) on the contents of $0.

Also, knowlegable users can set $0 to anything they want to at the time
that your script is started, before any of your code runs.  So if this 
is critical to your script's functionality (or security), think twice.

That said, I think it pretty safe to say that no Perl core or widely-used
modules are likely to change $0 at all.

Gary Ansok
-- 
Any attempt to brew coffee with a teapot should result in the error code
"418 I'm a teapot". The resulting entity body MAY be short and stout. 
        -- RFC 2324, Hyper Text Coffee Pot Control Protocol (HTCPCP)/1.0


------------------------------

Date: Fri, 24 Aug 2007 09:24:34 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Is there a better way of doing this?
Message-Id: <240820070924348208%jgibson@mail.arc.nasa.gov>

In article <1187946342.509055.110980@l22g2000prc.googlegroups.com>,
Bill H <bill@ts1000.us> wrote:

> In a script I have on a site I read all the values passed in the url
> (using the GET method) into an array called $query{'foo'} where foo is
> the name of the value. Though this has always worked fine I find
> myself assigning them to a new variable to make it easier to recognize
> them and quicker to type, for example I'll make $foo = $query{'foo'};
> 
> The question is, is there anything wrong with doing the following to
> automate this process, or is there a better "perl" way of doing the
> same?
> 
> 
> foreach $temp (keys(%query))
> {
>     eval("\$$temp = \$query{\$temp};");
> }

The main thing wrong with this method is that you lose control of what
you are defining. You have no idea what is being passed to your
program. While you know what values a legitimate submission of your
form page will pass, there is nothing preventing a malicious person
submitting a totally bogus URL that could contain anything. What if I
submitted such a URL that defined an already-defined variable, thereby
clobbering or hijacking your CGI program.

There also doesn't seem to be much point. If you only use a value once,
then just use $query{'foo'} (or just $query{foo}). If you use it more
than once, put my $foo = $query{foo}. How many variables do you have
that you can't have one line defining scalar variables to use in the
rest of your program?

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


------------------------------

Date: Fri, 24 Aug 2007 08:27:19 -0700
From:  "Larry W. Virden" <lvirden@gmail.com>
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <1187969239.246969.125910@z24g2000prh.googlegroups.com>

On Aug 23, 6:28 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> IO::Handle::close calls close() on the pipe and returns the value
> returned by close(). From 'perldoc close':
>
> "If the file handle came from a piped open, "close" will addi-
> tionally return false if one of the other system calls involved
> fails, or if the program exits with non-zero status.  (If the
> only problem was that the program exited non-zero, $! will be
> set to 0.)  Closing a pipe also waits for the process executing
> on the pipe to complete, in case you want to look at the output
> of the pipe afterwards, and implicitly puts the exit status
> value of that command into $?."
>
> So this program is already checking for the error return from close().
> There may not be much more that you can do except check the values of
> $! and $? if close returns an error.

More detail - and confusion.

Our perl is 5.8.4

Here's a smaller, hopefully more coherent example:

file 1
$ cat /tmp/displayerr.ksh
#! /bin/ksh

echo "This is stderr" >&2
echo "This is stdout"
cat
exit 3
$ cat tstio.pl
#! /bin/perl -w

use strict;
use IO::Pipe;

my $send = IO::Pipe->new();
$send->writer("/tmp/displayerr.ksh", 'REQUEST');
$send->print("This is just some output\n");
print "error 1 returns " . $send->error() . "\n";
if ($send->error()) {
        print "io error\n";
}
print "close returns " . $send->close() . "\n";
print "error 2 returns " . $send->error() . "\n";


And here's the peculiar thing:
$ ~/tstio.pl
error 1 returns 0
This is stderr
This is stdout
This is just some output
close returns 1
error 2 returns -1

$

This is the same output as I get if the ksh script exits with a 0 . So
I see no indication that the piped command has exited with a non-zero
return code.

It seems like the error() method isn't working as expected - or I am
totally misunderstanding its purpose.




------------------------------

Date: 24 Aug 2007 16:15:09 GMT
From: xhoster@gmail.com
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <20070824121510.732$L5@newsreader.com>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> In article <1187898656.403733.308310@m37g2000prh.googlegroups.com>,
> Larry W. Virden <lvirden@gmail.com> wrote:
>
> >
> > Within this code is some perl code that does basically this sort of
> > thing:
> >
> >             # Email request
> >             my $send = IO::Pipe->new();
 ....
> >             if ($send->close()) {
 ...
> >
> > The problem is that psend turns out to possibly exit with a non-zero
> > exit code if it has problems, and this calling program doesn't appear
> > to notice the fact that psend has failed.
>
> IO::Handle::close calls close() on the pipe and returns the value
> returned by close(). From 'perldoc close':
>
> "If the file handle came from a piped open, "close" will addi-
> tionally return false if one of the other system calls involved
> fails, or if the program exits with non-zero status.

But the handle here is *not* derived from a pipe open.  It is derived
from IO::Pipe->new() .  So that part of the docs do not apply.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 24 Aug 2007 16:48:04 GMT
From: xhoster@gmail.com
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <20070824124805.872$dE@newsreader.com>

"Larry W. Virden" <lvirden@gmail.com> wrote:
>
>             # Email request
>             my $send = IO::Pipe->new();
>             my $arch = `/bin/arch`;
>             chomp $arch;
>             $send->writer("/path/bin/$arch/psend", 'REQUEST');
>             my $a = $self->{'queue'};
>             for (my $indx = 0; $indx < @{$a}; $indx++) {
>                 my $r = $a->[$indx];
>                 $send->print(":$r->[0]");
>                 for (my $args = 1; $args < @{$r}; $args++) {
>                     (my $arg = $r->[$args]) =~ s!([\\"])!\\$1!g;
>                     $send->print(',"', $arg, '"');
>                 }
>                 $send->print("\n");
>             }
>             if ($send->close()) {
>                 my $msg = @{$a};
>                 delete $self->{'queue'};
>                 $self->{'queue'} = [ $sys ];
>                 return "$msg steps submitted";
>             }
>             $self->error('error: psend failed');
>             return undef;
>
> The problem is that psend turns out to possibly exit with a non-zero
> exit code if it has problems, and this calling program doesn't appear
> to notice the fact that psend has failed.
>
> So I have been asked to update it to :
>
> a. recognize that the program at the end of the IO::Pipe has failed
> and to exit with an error msg

You might be able to hack IO::Pipe to do this, but it would be better
to use something else altogether.

> b. pass any stderr messages back as part of the psend failed error
> message, so that the user has some chance of fixing the problem.

Normally what psend prints to stderr will end up on Perl's STDERR, so
if you log that you will have psend's error in your log file.  If you want
better granularity and control then that, you could use IPC::Open3 or
IPC::Run


> In reading the IO::Pipe and IO::Handle docs, I don't see a lot of
> detail about handling the remote program's error "exits".
>
> Does anyone have suggestions on what needs to happen? For instance,
> the info in IO::Handle mentions $self->error, but says that it is a
> boolean indicator; that doesn't seem like it is going to help me with
> accessing the error messages theirselves. I suppose the specific exit
> code won't be as big a deal as long as the error messages are unique.

IO::Pipe and IO::Handle are very general tools.  They can't be all
things to all people.  You want something specifically from running
external commands.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 24 Aug 2007 18:00:53 -0000
From:  Jie <jiehuang001@gmail.com>
Subject: push into hashs of arrays
Message-Id: <1187978453.093656.119270@x35g2000prf.googlegroups.com>

Hi,

I have a STUDENT_CLASS_FILE like below, basically a two column table
student1 class_A
student2 class_A
student3 class_B
 ....

now if someone gives me a class list, how I could generate the student
lists for each class?

I thought that I could use a code like below, but I don't know exactly
what to write for the third row...

Jie

################# MY PERL CODE#############3


while (STUDENT_CLASS_FILE) {
 ($student, $class) = split
 push @{$STUDENT_CLASS_HASH{$class}} ,$student ????????????
}

foreach $class (@CLASS_LIST) {
 $students = join ("," @{$STUDENT_CLASS_HASH{$class}} )
 print "$classs, $student\n"
}



------------------------------

Date: Fri, 24 Aug 2007 08:30:01 -0700
From:  "Larry W. Virden" <lvirden@gmail.com>
Subject: Re: Regular expression use
Message-Id: <1187969401.608508.137770@z24g2000prh.googlegroups.com>

On Aug 24, 6:58 am, n...@cus.cam.ac.uk (Nick Maclaren) wrote:
> I am interested in discovering what
> people actually use regular expressions for.

Hmm - let's see. I tend to use regular expressions when I am writing
code that needs to search through output to find certain patterns. I
also use them to convert text in one format into another format. I
also frequently use them to validate input - if I need input to be all
alphabetics, or a properly formatted floating point number, etc.



------------------------------

Date: Fri, 24 Aug 2007 12:43:55 -0400
From: brad <byte8bits@gmail.com>
Subject: Re: Regular expression use
Message-Id: <fan1vb$kv8$1@solaris.cc.vt.edu>

Nick Maclaren wrote:
> For reasons that I won't explain, as they are too complicated
> and not terribly relevant, I am interested in discovering what
> people actually use regular expressions for.

Finding credit card numbers in files...among other things:

http://filebox.vt.edu/users/rtilley/public/find_ccns/


------------------------------

Date: Fri, 24 Aug 2007 12:09:15 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: Starting with SOAP
Message-Id: <cnDzi.555$k22.341@read2.cgocable.net>

Amer Neely wrote:
> Ian Wilson wrote:
> 
>> Somewhere in one of the directories listed in @INC you should have
>> SOAP/Lite.pm
>> SOAP/Transport/HTTP.pm
>> SOAP/Transport/HTTP/CGI.pm
>> (and many other related modules)
> 
> I've re-installed SOAP-Lite from AS using ppm 4.01 GUI (actually 
> upgraded it to .69).
> 
> But I notice that I now have what seems to be 2 versions of it - one 
> under /usr/lib and one under /usr/site/lib
> 
> SOAP-Lite
> Interface to the Simple Object Access Protocol (SOAP)
>     Version:    0.55-r1
>     Released:    2005-07-19
>     Author:    Paul Kulchenko <paulclinger@yahoo.com>
>     CPAN:    http://search.cpan.org/dist/SOAP-Lite-0.55/
> 
> Installed files:
>     C:/usr/bin/SOAPsh.bat
>     C:/usr/bin/SOAPsh.pl
>     C:/usr/bin/XMLRPCsh.bat
>     C:/usr/bin/XMLRPCsh.pl
>     C:/usr/bin/stubmaker.bat
>     C:/usr/bin/stubmaker.pl
>     C:/usr/lib/Apache/SOAP.pm
>     C:/usr/lib/Apache/XMLRPC/Lite.pm
>     C:/usr/lib/IO/SessionData.pm
>     C:/usr/lib/IO/SessionSet.pm
>     C:/usr/lib/SOAP/Lite.pm
>     C:/usr/lib/SOAP/Test.pm
>     C:/usr/lib/SOAP/Transport/FTP.pm
>     C:/usr/lib/SOAP/Transport/HTTP.pm
>     C:/usr/lib/SOAP/Transport/IO.pm
>     C:/usr/lib/SOAP/Transport/JABBER.pm
>     C:/usr/lib/SOAP/Transport/LOCAL.pm
>     C:/usr/lib/SOAP/Transport/MAILTO.pm
>     C:/usr/lib/SOAP/Transport/MQ.pm
>     C:/usr/lib/SOAP/Transport/POP3.pm
>     C:/usr/lib/SOAP/Transport/TCP.pm
>     C:/usr/lib/UDDI/Lite.pm
>     C:/usr/lib/XML/Parser/Lite.pm
>     C:/usr/lib/XMLRPC/Lite.pm
>     C:/usr/lib/XMLRPC/Test.pm
>     C:/usr/lib/XMLRPC/Transport/HTTP.pm
>     C:/usr/lib/XMLRPC/Transport/POP3.pm
>     C:/usr/lib/XMLRPC/Transport/TCP.pm
>     C:/usr/lib/auto/SOAP/Lite/.packlist
> 
> 
> SOAP-Lite
> Perl's Web Services Toolkit
>     Version:    0.69
>     Author:    Byrne Reese <byrne@cpan.org>
>     CPAN:    http://search.cpan.org/dist/SOAP-Lite-0.69/
> 
> Installed files:
>     C:/usr/html/bin/SOAPsh.html
>     C:/usr/html/bin/XMLRPCsh.html
>     C:/usr/html/bin/stubmaker.html
>     C:/usr/html/site/lib/Apache/SOAP.html
>     C:/usr/html/site/lib/Apache/XMLRPC/Lite.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Lite.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/FTP.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/HTTP.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/IO.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/JABBER.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/LOCAL.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/MAILTO.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/MQ.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/POP3.html
>     C:/usr/html/site/lib/OldDocs/SOAP/Transport/TCP.html
>     C:/usr/html/site/lib/SOAP/Client.html
>     C:/usr/html/site/lib/SOAP/Constants.html
>     C:/usr/html/site/lib/SOAP/Data.html
>     C:/usr/html/site/lib/SOAP/Deserializer.html
>     C:/usr/html/site/lib/SOAP/Fault.html
>     C:/usr/html/site/lib/SOAP/Header.html
>     C:/usr/html/site/lib/SOAP/Lite.html
>     C:/usr/html/site/lib/SOAP/Packager.html
>     C:/usr/html/site/lib/SOAP/SOM.html
>     C:/usr/html/site/lib/SOAP/Schema.html
>     C:/usr/html/site/lib/SOAP/Serializer.html
>     C:/usr/html/site/lib/SOAP/Server.html
>     C:/usr/html/site/lib/SOAP/Test.html
>     C:/usr/html/site/lib/SOAP/Trace.html
>     C:/usr/html/site/lib/SOAP/Transport.html
>     C:/usr/html/site/lib/SOAP/Transport/POP3.html
>     C:/usr/html/site/lib/SOAP/Utils.html
>     C:/usr/html/site/lib/UDDI/Lite.html
>     C:/usr/html/site/lib/XML/Parser/Lite.html
>     C:/usr/html/site/lib/XMLRPC/Lite.html
>     C:/usr/html/site/lib/XMLRPC/Test.html
>     C:/usr/html/site/lib/XMLRPC/Transport/HTTP.html
>     C:/usr/html/site/lib/XMLRPC/Transport/POP3.html
>     C:/usr/html/site/lib/XMLRPC/Transport/TCP.html
>     C:/usr/site/bin/SOAPsh.bat
>     C:/usr/site/bin/SOAPsh.pl
>     C:/usr/site/bin/XMLRPCsh.bat
>     C:/usr/site/bin/XMLRPCsh.pl
>     C:/usr/site/bin/stubmaker.bat
>     C:/usr/site/bin/stubmaker.pl
>     C:/usr/site/lib/Apache/SOAP.pm
>     C:/usr/site/lib/Apache/XMLRPC/Lite.pm
>     C:/usr/site/lib/IO/SessionData.pm
>     C:/usr/site/lib/IO/SessionSet.pm
>     C:/usr/site/lib/OldDocs/SOAP/Lite.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/FTP.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/HTTP.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/IO.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/JABBER.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/LOCAL.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/MAILTO.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/MQ.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/POP3.pm
>     C:/usr/site/lib/OldDocs/SOAP/Transport/TCP.pm
>     C:/usr/site/lib/SOAP/Client.pm
>     C:/usr/site/lib/SOAP/Constants.pm
>     C:/usr/site/lib/SOAP/Data.pm
>     C:/usr/site/lib/SOAP/Deserializer.pm
>     C:/usr/site/lib/SOAP/Fault.pm
>     C:/usr/site/lib/SOAP/Header.pm
>     C:/usr/site/lib/SOAP/Lite.pm
>     C:/usr/site/lib/SOAP/Packager.pm
>     C:/usr/site/lib/SOAP/SOM.pm
>     C:/usr/site/lib/SOAP/Schema.pm
>     C:/usr/site/lib/SOAP/Serializer.pm
>     C:/usr/site/lib/SOAP/Server.pm
>     C:/usr/site/lib/SOAP/Test.pm
>     C:/usr/site/lib/SOAP/Trace.pm
>     C:/usr/site/lib/SOAP/Transport.pm
>     C:/usr/site/lib/SOAP/Transport/FTP.pm
>     C:/usr/site/lib/SOAP/Transport/HTTP.pm
>     C:/usr/site/lib/SOAP/Transport/IO.pm
>     C:/usr/site/lib/SOAP/Transport/JABBER.pm
>     C:/usr/site/lib/SOAP/Transport/LOCAL.pm
>     C:/usr/site/lib/SOAP/Transport/MAILTO.pm
>     C:/usr/site/lib/SOAP/Transport/MQ.pm
>     C:/usr/site/lib/SOAP/Transport/POP3.pm
>     C:/usr/site/lib/SOAP/Transport/TCP.pm
>     C:/usr/site/lib/SOAP/Utils.pm
>     C:/usr/site/lib/UDDI/Lite.pm
>     C:/usr/site/lib/XML/Parser/Lite.pm
>     C:/usr/site/lib/XMLRPC/Lite.pm
>     C:/usr/site/lib/XMLRPC/Test.pm
>     C:/usr/site/lib/XMLRPC/Transport/HTTP.pm
>     C:/usr/site/lib/XMLRPC/Transport/POP3.pm
>     C:/usr/site/lib/XMLRPC/Transport/TCP.pm
>     C:/usr/site/lib/auto/SOAP/Lite/.packlist
> 
> However, PPM will not let me delete the older version.
> 
> Could this be why I may be having some difficulties?

Finally got something to work.

I removed SOAP::Lite and re-installed it. Did some tweaking with my 
local client / server pair of scripts (thanks to the examples provided 
by xhoster I believe). I'm not sure the re-install had anything to do 
with my success - in fact I doubt it.

The client uses SOAP::Lite, but the server uses SOAP - go figure.

Of course now the trick is to get things to work under a different 
environment, and passing an actual variable. Sigh, back to crawling.

Much much thanks to all who responded - it's been another learning 
experience.

For those interested here are my 2 working scripts:
(Windows 2K Professional, AS Perl v5.8.8, Apache 2.2, SOAP::Lite 0.69)

#! /usr/bin/perl
## the 'server' half of SOAP
BEGIN
{
	open (STDERR,">>$0-err.txt");
	print STDERR "\n",scalar localtime,"\n";
}

use strict;
use warnings;
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('LarMar')
-> handle;

package LarMar;
sub ShowMe
{
	return "Hello from $0";
}
1;

------------------------ 8< cut here ------------------

#! /usr/bin/perl
## the 'client' half of SOAP

BEGIN
{
	open (STDERR,">>$0-err.txt");
	print STDERR "\n",scalar localtime,"\n";
}

use strict;
use warnings;

use SOAP::Lite qw (debug trace);

my $soap = SOAP::Lite
-> uri('LarMar')
-> proxy('http://localhost/cgi-bin/soap/larmar_server.pl');

print $soap
-> ShowMe()
-> result;
------------------------ 8< cut here ------------------

-- 
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"


------------------------------

Date: 24 Aug 2007 17:01:03 GMT
From: xhoster@gmail.com
Subject: Re: Threaded Perl Processes Going to Sleep Simultaneously??? Why?
Message-Id: <20070824130104.908$Ew@newsreader.com>

"Roycedot@gmail.com" <Roycedot@gmail.com> wrote:
> Hi,
>
> I've written a Perl program that creates 10 threads (ithreads) and
> each thread operates on a different part of a large array.  The large
> array is just a file read in before the threads are started.

Either this large array is marked shared, and thus you are sharing
a large array, or you it is not marked shared and thus you are replicating
a large array 10 times.  I don't know which one of these prospects
is less enticing.


> Each
> thread processes a chunk of the array and then prints the processed
> output to a shared text file.
>
> I run different instances of this Perl program so I can process
> multiple files,

So you have multiple processes, each of which has 10 threads?

> but oddly all instances of this program go to sleep at
> the same time and then come back at the same time.  At least this is
> what I see with the 'top' command in Linux.

I don't see why that is surprising.  Say there is some resource that all of
your jobs are trying to use, the hard drive, the network, whatever.  If
that resource freezes up temporarily (say, because 4 processes with 10
threads for a total of 40 things are beating it over the head), all your
jobs will block waiting for it to come back.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 791
**************************************


home help back first fref pref prev next nref lref last post