[23208] in Perl-Users-Digest
Perl-Users Digest, Issue: 5429 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 2 14:10:43 2003
Date: Tue, 2 Sep 2003 11:10:17 -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 Tue, 2 Sep 2003 Volume: 10 Number: 5429
Today's topics:
Re: Safely eval code from text file--suggestions? <jaspax@u.washington.edu>
Silly push tricks <jill_krugman@yahoo.com>
Re: Silly push tricks <shawn@magma.ca>
Re: Silly push tricks (Greg Bacon)
Re: Silly push tricks <wksmith@optonline.net>
Re: Silly push tricks <uri@stemsystems.com>
Re: Silly push tricks <jill_krugman@yahoo.com>
Re: SOAP::Lite - serve a complex "object"? <spambait@null.com>
Re: Trouble With IPC::Shareable <jwillmore@cyberia.com>
write hex to socket, weird <ask-me@internet.com>
Re: write hex to socket, weird (Greg Bacon)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 2 Sep 2003 10:18:14 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Safely eval code from text file--suggestions?
Message-Id: <Pine.A41.4.56.0309021013550.133438@dante38.u.washington.edu>
Benjamin Goldberg sikyal:
> use Safe;
> if( exists $code{$_} ) {
> (my $safe = Safe->new)->permit_only(qw(:default));
> my $c = $safe->reval("return sub { $parse->{$_} }");
> if ($@) {
> err("Errors processing $_ : $@");
> } else {
> $self->$_($c);
> }
> }
>
> [untested; might not *really* be Safe]
This works very well. Thank you! I hadn't ever heard of the Safe module
before, so thanks for pointing this out to me.
> Of course, since you've been wholly trusting the contents of $parse->{$_}
> so far (meaning, *anything* could have been done in it's code), you wouldn't
> be doing any *worse* to eval the code inside of a Safe object.
Right. I'm actually letting general security issues within the code in
$parse->{$_} be Somebody Else's Problem. As the module writer, I need to
make sure that the code doesn't alter the internals of my module, but
making sure that the code doesn't maliciously use system() calls or do
other insecure buggery will be the responsibility of the person using the
module and providing the XML to parse.
--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
Jesus asked them, "Who do you say that I am?"
And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."
And Jesus said, "What?"
------------------------------
Date: Tue, 2 Sep 2003 14:12:34 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Silly push tricks
Message-Id: <bj28gi$2in$1@reader2.panix.com>
I would like to write something like
push &test($_) ? @sheep : @goats, $_ for @bleats;
but I get the error
Type of arg 1 to push must be array (not null operation)
Of course, I can break down and roll out something like
for ( @bleats ) {
if ( &test($_) ) {
push @sheep, $_
}
else {
push @goats, $_
}
}
...but, I'm curious, is there a way I can coax push into accepting
the one-line construct?
Thanks,
-Jill
------------------------------
Date: Tue, 02 Sep 2003 10:24:07 -0400
From: Shawn Corey <shawn@magma.ca>
Subject: Re: Silly push tricks
Message-Id: <3l6dnaqT0_d6OsmiU-KYvg@magma.ca>
J Krugman wrote:
> I would like to write something like
>
> push &test($_) ? @sheep : @goats, $_ for @bleats;
>
> but I get the error
>
> Type of arg 1 to push must be array (not null operation)
>
> Of course, I can break down and roll out something like
>
> for ( @bleats ) {
> if ( &test($_) ) {
> push @sheep, $_
> }
> else {
> push @goats, $_
> }
> }
>
> ...but, I'm curious, is there a way I can coax push into accepting
> the one-line construct?
>
> Thanks,
>
> -Jill
map{&test($_)?push@sheep,$_:push@goats,$_}@bleats;
------------------------------
Date: Tue, 02 Sep 2003 14:37:27 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Silly push tricks
Message-Id: <vl9ap77ulhjef9@corp.supernews.com>
In article <bj28gi$2in$1@reader2.panix.com>,
J Krugman <jill_krugman@yahoo.com> wrote:
: I would like to write something like
:
: push &test($_) ? @sheep : @goats, $_ for @bleats;
:
: but I get the error
:
: Type of arg 1 to push must be array (not null operation)
The compiler used to accept this back in the day, but now we have
to be a little more explicit:
push @{ &test($_) ? \@sheep : \@goats }, $_ for @bleats;
Hope this helps,
Greg
--
This is the great illusion of our age, the idea that a certain class of
people [i.e., government] is exempt from the moral judgments that apply
to the rest of us.
-- Gene Callahan
------------------------------
Date: Tue, 02 Sep 2003 15:29:14 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Silly push tricks
Message-Id: <eH25b.118653$yg.34091232@news4.srv.hcvlny.cv.net>
"Shawn Corey" <shawn@magma.ca> wrote in message
news:3l6dnaqT0_d6OsmiU-KYvg@magma.ca...
--snip--
> map{&test($_)?push@sheep,$_:push@goats,$_}@bleats;
>
I think that it is poor style to use 'map' when the return value is not
used. Use 'foreach' instead. My extra parens may not be necessary, but
I do not trust my memory of precedence rules.
Bill
&test($_)?push(@sheep,$_):push(@goats,$_) foreach @bleats;
------------------------------
Date: Tue, 02 Sep 2003 15:43:02 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Silly push tricks
Message-Id: <x74qzvurga.fsf@mail.sysarch.com>
>>>>> "SC" == Shawn Corey <shawn@magma.ca> writes:
SC> map{&test($_)?push@sheep,$_:push@goats,$_}@bleats;
avoid map in a void context.
avoid & for calling subs
ever heard of whitespace?
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
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Tue, 2 Sep 2003 16:38:25 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: Silly push tricks
Message-Id: <bj2h21$5l0$1@reader2.panix.com>
In <vl9ap77ulhjef9@corp.supernews.com> gbacon@hiwaay.net (Greg Bacon) writes:
> push @{ &test($_) ? \@sheep : \@goats }, $_ for @bleats;
Thanks!
------------------------------
Date: Tue, 2 Sep 2003 10:45:53 -0700
From: "J. Patrick Brandt" <spambait@null.com>
Subject: Re: SOAP::Lite - serve a complex "object"?
Message-Id: <KG45b.11088$QT5.8687@fed1read02>
Partial answer/hack to the question.
1) Manually change the generated proxy class for "outdata". (this is bad)
Replace:
[System.Xml.Serialization.SoapElementAttribute(DataType="integer")]
public string outint;
With:
public int outint;
2) Change the perl service (this is ugly)
Replace:
return bless \%outdata;
With:
return SOAP::Data->name("outargs" =>
\SOAP::Data->value(SOAP::Data->name("outstr" => $outdata
{ 'outstr' }),
SOAP::Data->name("outint" => $outdata
{ 'outint' })));
This alters the output from:
<SOAP-ENV:Body>
<namesp1:complexArgsResponse xmlns:namesp1="sample_class">
<sample_class xsi:type="namesp2:sample_class">
<outstr xsi:type="xsd:string">string part</outstr>
<outint xsi:type="xsd:int">54321</outint>
</sample_class>
</namesp1:complexArgsResponse>
</SOAP-ENV:Body>
Note: "sample_class" instead of "outargs", and the extra namesp2:
to:
<SOAP-ENV:Body>
<namesp1:complexArgsResponse xmlns:namesp1="sample_class">
<outargs>
<outstr xsi:type="xsd:string">string part</outstr>
<outint xsi:type="xsd:int">54321</outint>
</outargs>
</namesp1:complexArgsResponse>
</SOAP-ENV:Body>
Now the .NET client is happy...
3) Note: The perl client still works.
*** Follow-up question (will clean up and post on a new thread):
Is there an easier way to get the desired output without the compound
SOAP::Data statements?
------------------------------
Date: Tue, 02 Sep 2003 16:43:52 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Trouble With IPC::Shareable
Message-Id: <20030902124344.393cb474.jwillmore@cyberia.com>
On Tue, 02 Sep 2003 04:55:55 GMT
mooseshoes <mooseshoes@gmx.net> wrote:
> <snip>
>
> > Hum ... $! ... holds the latest OS error.
> > I'm thinking that - your code is _not_ printing this wonderful
> > variable - and what Nicholas was alluding to.
> >
> > For example:
> > tie %hash, 'IPC::Shareable', $glue, { %options } or die "server:
> > tie failed - $!\n";
> >
> > Notice the $! variable in the line.
> >
> > perldoc perlvar for more info
> >
> > HTH
> <<< James, the output, including that of $! in this case would
> normally go to the web page but the error message does not appear.
> Perhaps I am missing your meaning.
Perhaps I am missing your meaning as well. If you're running this
script through the CGI, the error messages from the script _should_
show up in the server's error log file (including '$!'). And ... if
you can run the script from the command line, then you'll be able to
see '$!' without a browser. And ... if you are bound by the fact that
it _has_ to run through the CGI and you have no access to the logs,
you _can_ use CGI::Carp (just not in a production environment).
So, I'm at a loss as to what you're refering to when you say you
_can't_ see the error message (browser or not). The code you
provided as an example was missing '$!'. If you put '$!' in the 'die'
statement and then run the script, there _will_ be a way to see the
error - if there is one.
--
Jim
---
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
---
a real quote ...
Linus Torvalids: "They are somking crack ...."
(http://www.eweek.com/article2/0,3959,1227150,00.asp)
---
a fortune quote ...
Fourth Law of Revision: It is usually impractical to worry
beforehand about interferences -- if you have none, someone will
make one for you.
------------------------------
Date: 02 Sep 2003 15:35:46 GMT
From: "c|sc0" <ask-me@internet.com>
Subject: write hex to socket, weird
Message-Id: <3f54b8d2$0$6243$626a54ce@news.free.fr>
Hi,
I just want to write raw data to a socket (by using IO::Socket)
All I want to do is the following:
print $my_socket "\x0f\xa1\x02.....and much more here";
A part of the data is actually an IP address
so in my case if I want to send "10.1.2.3" I should send "\x0a\01\x02\x3"
I tried to create a sub() to generate the "\x0a\01\x02\x3" out of
"10.1.2.3", but I failed.
Obviously the following does not work:
$code .= "\\x" . substr( unpack("H*", pack("N*", $my_byte)) , -2 ,2);
I tried many more ways but still can't achieve it.
I'd like to do such a sub() for "string" as well
e.g "ABC" should give "\x41\x42\x43"
but as you already understood, i dont want the string "\x41\x42\x43" but
the actually value behind it.
Can you guys give a tip ?
thanks
C|sc0-
------------------------------
Date: Tue, 02 Sep 2003 15:55:14 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: write hex to socket, weird
Message-Id: <vl9fb2oblnmbfe@corp.supernews.com>
In article <3f54b8d2$0$6243$626a54ce@news.free.fr>,
c|sc0 <ask-me@internet.com> wrote:
: [...]
:
: I tried to create a sub() to generate the "\x0a\01\x02\x3" out of
: "10.1.2.3", but I failed.
:
: Obviously the following does not work:
:
: $code .= "\\x" . substr( unpack("H*", pack("N*", $my_byte)) , -2 ,2);
Do the hosts on the ends of your connection have different byte orders?
Here's a rough start:
% cat try
#! /usr/bin/perl
use warnings;
use strict;
sub ip2hex {
join '' => map chr($_) => split /\./, shift;
}
for (split //, ip2hex '10.1.2.3') {
printf "%02x\n", ord($_);
}
% ./try
0a
01
02
03
: [...]
Hope this helps,
Greg
--
Democracy is the theory that the common people know what they want, and
deserve to get it good and hard.
-- H. L. Mencken
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5429
***************************************