[24033] in Perl-Users-Digest
Perl-Users Digest, Issue: 6230 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 7 18:05:38 2004
Date: Sun, 7 Mar 2004 15:05:06 -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 Sun, 7 Mar 2004 Volume: 10 Number: 6230
Today's topics:
Re: Converting OLE objects <matthew.garrish@sympatico.ca>
Extract data using Curl Unix Command & Perl Script from (Fiaz Idris)
Re: Extract data using Curl Unix Command & Perl Script <invalid-email@rochester.rr.com>
Re: Extract data using Curl Unix Command & Perl Script <tadmc@augustmail.com>
Re: Extract data using Curl Unix Command & Perl Script <gnari@simnet.is>
Re: HOW TO CHECK URL?? <rhersiczky@cuthere-hotmail.com>
Re: MS SQL 2000 <x@y.com>
Re: MS SQL 2000 <x@y.com>
Re: Need help with Undeliverable Emails <jwillmore@remove.adelphia.net>
Re: Need help with Undeliverable Emails <whoknows@NoSpamPLZ.net>
Re: Need help with Undeliverable Emails <jwillmore@remove.adelphia.net>
Re: Nested arrays <rhersiczky@cuthere-hotmail.com>
Pre-release of pragmatic module base::hasa (Anno Siegel)
Re: replacing modules? <tassilo.parseval@rwth-aachen.de>
Re: replacing modules? (Anno Siegel)
Re: SOAP::Lite in a Safe ? <jwillmore@remove.adelphia.net>
Re: SOAP::Lite in a Safe ? <wherrera@lynxview.com>
Re: SOAP::Lite in a Safe ? <usenet@morrow.me.uk>
Re: socket communication / callback <usenet@morrow.me.uk>
Re: socket communication / callback <remove_Hannes.Krueger@uibk.ac.at>
String Search containing a '/' character <bumble@what.the.heck>
Re: String Search containing a '/' character (Anno Siegel)
Re: String Search containing a '/' character <gnari@simnet.is>
Re: triggering callback from "outside" <xxala_qumsiehxx@xxyahooxx.com>
Re: using C++ from perl <rhersiczky@cuthere-hotmail.com>
What could cause Time::Hires to fail? <admin@asarian-host.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 7 Mar 2004 17:38:58 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Converting OLE objects
Message-Id: <%vN2c.1277$6y1.166833@news20.bellglobal.com>
"Pradeep George Jacob Kalampukattussery" <PKalampukattussery@nc.rr.com>
wrote in message news:Idu2c.71930$eL2.4152815@twister.southeast.rr.com...
> Hello-
> I have OLE objects (mostly word and excel) stored in a field in an Oracle
> database. I need to extract them and save them as files on the filesystem
> (MS Word and MS Excel files).
> I used the DBI module to query the database and get the OLE into a scalar
> variable - I read through the Win32::OLE module but didn't get a clue on
how
> to convert data stored in a variable and save as a file.
> Maybe there is a better approach to what I need to do.
>
Is OLE::Storage_Lite what you're looking for?
http://aspn.activestate.com/ASPN/CodeDoc/OLE-Storage_Lite/Storage_Lite.html
Matt
------------------------------
Date: 7 Mar 2004 09:00:38 -0800
From: ifiaz@hotmail.com (Fiaz Idris)
Subject: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <93c1947c.0403070900.913fbb2@posting.google.com>
I have used curl and perl script to extract data from sequence
of webpages before.
But, in the following case I couldn't find a way to do it.
So, if someone can guide me a better way or add any comments
on top of my own to do it would be appreciated.
HOW I EXPECT IT TO BE DONE
--------------------------
The webpage is the following:
http://www.chennaionline.com/msuniversity/submit.asp?code=BA
and I have to extract the Registration numbers from 2225683 to
2225867.
You might want to try out a single number for e.g. 2225683 to see
the results it returns.
I normally will group all the webpage source of each of the
registration
numbers in a single file using something like
$results = qx{curl -s
http://www.chennaionline.com/msuniversity/result.asp?RegistraitonNumber=$regno};
redirected to a file and then use regular expressions to extract the
Registration No., Name, College and the marks & results of each
subject
for each student.
WHAT I EXPECT FROM YOU
----------------------
I can't find a correct way to locate the URL which will return the
results
of each Registration Number as it seems to be using JavaScript or
something.
How can I do it in this case?
If there is a complete alternative to do it. Please guide me.
I have used the same technique in some other pages and it works like a
wonder.
------------------------------
Date: Sun, 07 Mar 2004 20:01:33 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <404B7E7A.2060804@rochester.rr.com>
Fiaz Idris wrote:
> I have used curl and perl script to extract data from sequence
> of webpages before.
>
> But, in the following case I couldn't find a way to do it.
>
> So, if someone can guide me a better way or add any comments
> on top of my own to do it would be appreciated.
>
> HOW I EXPECT IT TO BE DONE
> --------------------------
>
> The webpage is the following:
>
> http://www.chennaionline.com/msuniversity/submit.asp?code=BA
>
> and I have to extract the Registration numbers from 2225683 to
> 2225867.
>
> You might want to try out a single number for e.g. 2225683 to see
> the results it returns.
>
> I normally will group all the webpage source of each of the
> registration
> numbers in a single file using something like
>
> $results = qx{curl -s
> http://www.chennaionline.com/msuniversity/result.asp?RegistraitonNumber=$regno};
Accuracy counts------------------------------------------------^^
>
> redirected to a file and then use regular expressions to extract the
> Registration No., Name, College and the marks & results of each
> subject
> for each student.
>
> WHAT I EXPECT FROM YOU
> ----------------------
>
> I can't find a correct way to locate the URL which will return the
> results
> of each Registration Number as it seems to be using JavaScript or
> something.
>
> How can I do it in this case?
The HTML page generating the request indicates it is using the POST
method. Perhaps the CGI script which accepts the request checks to
verify that the POST method was used? In the case of the POST method,
the arguments are not supplied as part of the URL.
>
> If there is a complete alternative to do it. Please guide me.
use LWP::UserAgent;
would be the Perlish way of doing it. See:
perldoc lwpcook
for a tutorial.
>
> I have used the same technique in some other pages and it works like a
> wonder.
Did their forms use the POST method?
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 7 Mar 2004 14:59:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <slrnc4n3a1.vbk.tadmc@magna.augustmail.com>
Fiaz Idris <ifiaz@hotmail.com> wrote:
> I have used curl and perl script to extract data from sequence
> of webpages before.
Why not just ditch curl and do it with Perl alone?
See this Perl FAQ:
How do I automate an HTML form submission?
> But, in the following case I couldn't find a way to do it.
>
> So, if someone can guide me a better way
I like to use the Web Scraping Proxy (wsp.pl) for developing
my many web-scraping programs:
http://www.research.att.com/~hpk/wsp/
It is a huge timesaver in reverse-engineering how to get to what you want.
> The webpage is the following:
>
> http://www.chennaionline.com/msuniversity/submit.asp?code=BA
>
> and I have to extract the Registration numbers from 2225683 to
> 2225867.
> redirected to a file and then use regular expressions to extract the
Using regular expressions to parse HTML can be a bad idea.
Especially since the data you want is in a table.
Use the HTML::TableExtract module instead of fragile regexes.
> I can't find a correct way to locate the URL which will return the
> results
See where it says
<form name="examresult" action="result.asp" method="post">
??
You take the "submit.asp..." stuff off of the URL that you got
the <form> page from, and put "result.asp" in its place.
http://www.chennaionline.com/msuniversity/result.asp
> How can I do it in this case?
Let wsp.pl write a request for you (you'll probably need to edit it a bit),
and use the LWP::UserAgent module to submit the request.
> If there is a complete alternative to do it. Please guide me.
Here you go:
----------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::TableExtract;
use Data::Dumper;
my($num, $name, $college, @lines) = get_grades( '2225684' );
print "num: $num\n";
print "name: $name\n";
print "college: $college\n";
print Dumper \@lines;
sub get_grades {
my($id) = @_;
my $request = POST "http://www.chennaionline.com/msuniversity/result.asp",
[
'Codeid' => "BA",
'Exam_Registration_Number' => $id,
] ;
my $agent = new LWP::UserAgent();
my $response = $agent->request( $request );
return() unless $response->is_success;
my $content = $response->content();
### Registration No., Name, College (by table position)
my $te = new HTML::TableExtract( count => 2, depth => 1 );
$te->parse($content);
my($table) = $te->tables();
my @rows = $te->rows($table);
my $regnum = $rows[0][1];
my $name = $rows[1][1];
my $college = $rows[2][1];
### grades (by table headers)
$content =~ s/Subject\s*Code/Subject Code/; # patch silly web page
$te = new HTML::TableExtract( headers => ['Subject Code',
'Marks',
'Result'
]
);
$te->parse($content);
@rows = (); # re-used from above
foreach my $ts ($te->table_states) {
foreach my $row ($ts->rows) {
next if $row->[0] =~ /CONTROLLER OF EXAMINATION/;
my %course;
@course{ qw/subject marks result/ } = @$row; # a "hash slice"
push @rows, \%course;
}
}
return $regnum, $name, $college, @rows;
}
----------------------------------------
Web scraping is a blast!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 7 Mar 2004 20:34:57 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <c2g0ve$jht$1@news.simnet.is>
"Fiaz Idris" <ifiaz@hotmail.com> wrote in message
news:93c1947c.0403070900.913fbb2@posting.google.com...
[snip]
> $results = qx{curl -s
>
http://www.chennaionline.com/msuniversity/result.asp?RegistraitonNumber=$reg
no};
>
> ...
>
> WHAT I EXPECT FROM YOU
what we in turn can expect from you, is that you do a modicum of preparation
work, like making sure the url you claim does not work, is actually the
correct one
a cursory look at the html show that the input field is actually not
RegistraitonNumber , but rather Exam_Registration_Number
in addition to that there is a hidden field Codeid set to 'BA'.
and to be sure, maybe you should also include the button field,
btn_display=Results
try that, preferably with a POST
if it still fails try to set the Referer HTTP header
gnari
------------------------------
Date: Sun, 7 Mar 2004 19:08:15 +0100
From: "Reto Hersiczky" <rhersiczky@cuthere-hotmail.com>
Subject: Re: HOW TO CHECK URL??
Message-Id: <404b6512$0$719$5402220f@news.sunrise.ch>
use LWP::Simple;
my ($content_type, $document_length, $modified_time) = head $ARGV[0];
print $content_type ? 'OK' : 'FAIL', "\n";
--retoh :)
"news.hinet.net" <luke@program.com.tw> wrote in message
news:c2cjuq$eeh@netnews.hinet.net...
> HTTP://123.22.1.33 TRUE
> HTTP://123.22.1.333 FAIL
> http://123.22.1 fail
>
> ftp://abc.efg.net true
> ftp://abc.efg.nnn fail
> http://abc.efg*.net fail
------------------------------
Date: Sun, 07 Mar 2004 18:05:54 GMT
From: Jim <x@y.com>
Subject: Re: MS SQL 2000
Message-Id: <6wJ2c.76119$eL2.4230724@twister.southeast.rr.com>
my $dbhandle = DBI->connect(
"DBI:ADO:DRIVER={SQL Server};SERVER=$servername;DATABASE=$dbname",
$uid, $pwd,{ RaiseError => [1],
PrintError => [1],
AutoCommit => [1])
) || die "Db connection not made: $DBI::errstr";
anonymous@coolgroups.com wrote:
> Does anyone know how to connect to an MS SQL 2000 db from
> Perl?
>
> thanks.
>
------------------------------
Date: Sun, 07 Mar 2004 18:09:21 GMT
From: Jim <x@y.com>
Subject: Re: MS SQL 2000
Message-Id: <lzJ2c.76146$eL2.4230724@twister.southeast.rr.com>
Oh yeah,
use DBI;
use DBI qw(:sql_types);
> my $dbhandle = DBI->connect(
> "DBI:ADO:DRIVER={SQL Server};SERVER=$servername;DATABASE=$dbname",
> $uid, $pwd,{ RaiseError => [1],
> PrintError => [1],
> AutoCommit => [1])
> ) || die "Db connection not made: $DBI::errstr";
>
>
> anonymous@coolgroups.com wrote:
>
>> Does anyone know how to connect to an MS SQL 2000 db from Perl?
>>
>> thanks.
>>
------------------------------
Date: Sun, 07 Mar 2004 10:01:13 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Need help with Undeliverable Emails
Message-Id: <pan.2004.03.07.15.01.11.368387@remove.adelphia.net>
On Sun, 07 Mar 2004 14:51:10 +1100, Paul B wrote:
> Thats to all those who helped.
>
> I have found the answer.
>
> $mailprog = /usr/sbin/sendmail;
>
> open $mailprog -t -t $recipient;
You've also found something that could be unsafe :-)
You should, IMHO, stick with a pure Perl solution - such as Net::SMTP.
Good luck!
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Love is a snowmobile racing across the tundra and then suddenly
it flips over, pinning you underneath. At night, the ice weasels
come." -- Matt Groening
------------------------------
Date: Sun, 07 Mar 2004 15:18:28 GMT
From: whoknows <whoknows@NoSpamPLZ.net>
Subject: Re: Need help with Undeliverable Emails
Message-Id: <83H2c.617$RF2.117367@wagner.videotron.net>
On Sun, 07 Mar 2004 10:01:13 -0500, James Willmore wrote:
>
> You've also found something that could be unsafe :-)
> You should, IMHO, stick with a pure Perl solution - such as Net::SMTP.
>
- It can be unsafe to run sendmail as daemon, not to use it as a client
to send mail out.
- Postfix has a binary named sendmail too and Postfix _is_ secure.
- Does Net::SMTP will queue your messages in case of mail server outage?
- Will it try multiple servers?
Basicaly if you don't mind (potentialy) loosing mail Net::SMTP is fine,
otherwise sendmail is the way to go.
--
.signature: No such file or directory
------------------------------
Date: Sun, 07 Mar 2004 10:55:05 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Need help with Undeliverable Emails
Message-Id: <pan.2004.03.07.15.55.03.635555@remove.adelphia.net>
On Sun, 07 Mar 2004 15:18:28 +0000, whoknows wrote:
> On Sun, 07 Mar 2004 10:01:13 -0500, James Willmore wrote:
>>
>> You've also found something that could be unsafe :-) You should, IMHO,
>> stick with a pure Perl solution - such as Net::SMTP.
>>
>>
> - It can be unsafe to run sendmail as daemon, not to use it as a client
> to send mail out.
The code used to do so *is* a potential security risk. There are many
references as to why. Start here in clpm, then move onto Google :-)
> - Postfix has a binary named sendmail too and Postfix _is_ secure.
I use Postfix as well for the same reason, but *never* use the client
without good reason. Maybe that's just me, but I prefer to know *exactly*
what's being sent out and to where. Again, the code referenced by the OP
does not insure that (no mention of taint checking or validation of the
variable used for the message - very dangerous). Just because the
*binary* is "secure" doesn't mean the human interface can't make it
"un-secure".
> - Does Net::SMTP will queue your messages in case of mail server outage?
There is a 'SkipBad' setting, which will still send email to valid
addresses even if other addresses are seen as bad by the server. There is
also the 'Debug' setting which will allow you to see the conversation
between the script and the server - so you can see *why* the address is
seen as bad. And queuing a message ... that's the responsibility of the
server - the client should only be concerned with sending the email.
Either it's sent or not :-)
On the chance your email(s) are not sent, the script should let you know
is some efficient fashion (like maintaining a log and ... checking the log
to see if all went well :-) ). And, if it's a critical activity to send
out emails, you should be writing the emails out to file in case they get
lost in transit. Queuing the messages will do not good if they get lost
in the queue because of some fatal error to your system - or due to some
error on the part of the "human interface" (aka user error) :-)
> - Will it try multiple servers?
And why would you want to :-) If you have that many issues with the
server, the problem isn't the script, it's the server you're sending to
:-) Sending to multiple servers seems more like sending spam than legit
email. There should not be any reason to send to multiple SMTP servers.
Do you do this with your favorite email client? The same messages? If
so, again, the problem lies with your ISP, not your client :-)
> Basicaly if you don't mind (potentialy) loosing mail Net::SMTP is fine,
> otherwise sendmail is the way to go.
There's nothing wrong with the Net::SMTP module. All your statements are
really based upon FUD. I guess you could argue the same way. I doubt it,
but I guess you could :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Grandpa Charnock's Law: You never really learn to swear until
you learn to drive.
------------------------------
Date: Sun, 7 Mar 2004 18:48:04 +0100
From: "Reto Hersiczky" <rhersiczky@cuthere-hotmail.com>
Subject: Re: Nested arrays
Message-Id: <404b6050$0$705$5402220f@news.sunrise.ch>
Against PHP, hashes are widely used in Perl.
And yes, Perl makes a certain difference between hashes and arrays.
Using arrays and hashes in Perl is easy. Complexity begins when you
continue to work with references to these data types.
It can be powerful to combine these two data types, e.g. you might
assign a reference of an array to a hash key. The benefit of the
performance might be worth the cost of complexity.
Find some code examples of nested hashes in Perl on
http://www.infocopter.com/perl/hashes.htm
Recursion is of unlimited depth as the general philosophy in Perl itself.
--retoh :)
--
"Sandman" <mr@sandman.net> wrote in message
news:mr-12CDF3.23193804032004@news.fu-berlin.de...
> Using php, an array definition might look like this:
>
> $foo = array(
> "foo" => array("foo", "bar"),
> "bar" => array("rab", "oof")
> );
>
> print $foo["foo"][0];
>
> ...would print "foo"
>
> $foo = array(
> "foo" => array("foo" => "orange", "bar" => "apple"),
> "bar" => array("rab" => "pear", "oof" => "pineapple")
> );
>
> print $foo["foo"][0];
> print $foo["foo"]["foo"];
>
> ...would both print "orange".
>
> How would the syntax be in perl? Perl differantiates betwen hashes and
arrays,
> and in php an array is an hash and an array at the same time (i.e. every
key in
> the array exists as both named and as index).
>
> --
> Sandman[.net]
------------------------------
Date: 7 Mar 2004 17:56:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Pre-release of pragmatic module base::hasa
Message-Id: <c2fnog$2h9$2@mamenchi.zrz.TU-Berlin.DE>
I am preparing a pragmatic module "base::hasa" for release on CPAN. As
usual at this stage, there is an urge to get some feedback before casting
things in stone. ("Cast in stone"? Hmmm.) So I have put up a pre-release
under
http://www.tu-berlin.de/~siegel/clpm/base-hasa/
From the doc:
NAME
base::hasa - 'Turn has-a relation into is-a (experimental)'
SYNOPSIS
package My::Class;
# My::Class wants to inherit from Base::Class.
# There is a has-a relation to Base::Class in the sense that
# there is a method "hasa_method" in My::Class that returns
# a Base::Class object.
# To establish inheritance:
use base::hasa ( 'Base::Class' => 'hasa_method');
DESCRIPTION
"base::hasa" establishes an "is-a" relationship with the base class
"Base::Class". In addition, inherited methods are channeled through
the "has_a" method.
Thus, if "foo" is a method of "Base::Class", it is now immediately
applicable to an object $mine in your inheriting class "My::Class":
$mine->foo( ...);
is equivalent to
$mine->hasa_method->foo( ...);
[...]
Note that with has-a inheritance, knowledge about the base class is
entirely encapsulated in the has-a relationship. This is no matter of
course in Perl OO.
[see full text at the URL above]
I'd be thankful if anyone could find the time and interest to take a look.
The module is functional, but it is barely debugged and I would not be
surprised if it broke easily. Bug reports will be gratefully accepted,
but that is not my main reason for posting. I'll be writing tests for the
next few days anyway...
I have the feeling that base::hasa proves something about Perl OO that
might have been doubted, but I can't quite put my finger on it. "You
never could inherit with knowing less about your base class" is a
short way of putting it. I call this, somewhat clumsily, "has-a
inheritance". The (preliminary) section COGITATIONS in
the doc contains more on this. I'd be particularly grateful for
thoughts about what role "has-a inheritance" plays in the greater scheme
of things OO.
Oh, something else... I wrongly thought that Time::Piece was a standard
module, and the documentation and examples (in examples/ex_*) freely use
it. You may want to get it from CPAN if you want to play with base::hasa.
Sorry about that.
Anno
------------------------------
Date: 7 Mar 2004 16:57:24 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: replacing modules?
Message-Id: <c2fk9k$kln$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Anno Siegel:
> Torsten Mohr <tmohr@s.netic.de> wrote in comp.lang.perl.misc:
>> Hi,
>>
>> if i load a module by something like:
>>
>> use module;
>>
>> then i could also just load all the functions in module.pm
>> into my own script and everything is fine.
>> This works for some modules.
>
> It works better if you put the text of the foreign module into a BEGIN
> block where the "use" statement used to be. Immediately following,
> add another block
>
> BEGIN { Module->import( ...) if Module->can( 'import') }
You can even drop the 'if' altogether. The 'import' method is special in
that perl will silently turn 'Module->import' into a no-op if this
method isn't inherited nor defined by Module.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 7 Mar 2004 17:48:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: replacing modules?
Message-Id: <c2fna6$2h9$1@mamenchi.zrz.TU-Berlin.DE>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Anno Siegel:
>
> > Torsten Mohr <tmohr@s.netic.de> wrote in comp.lang.perl.misc:
> >> Hi,
> >>
> >> if i load a module by something like:
> >>
> >> use module;
> >>
> >> then i could also just load all the functions in module.pm
> >> into my own script and everything is fine.
> >> This works for some modules.
> >
> > It works better if you put the text of the foreign module into a BEGIN
> > block where the "use" statement used to be. Immediately following,
> > add another block
> >
> > BEGIN { Module->import( ...) if Module->can( 'import') }
>
> You can even drop the 'if' altogether. The 'import' method is special in
> that perl will silently turn 'Module->import' into a no-op if this
> method isn't inherited nor defined by Module.
Ah... I didn't know this. I must have falsely accused a few good
programmers of sloppiness because of that :)
Anno
------------------------------
Date: Sun, 07 Mar 2004 10:12:51 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: SOAP::Lite in a Safe ?
Message-Id: <pan.2004.03.07.15.12.49.526656@remove.adelphia.net>
On Sat, 06 Mar 2004 21:36:31 -0700, Bill wrote:
> Anyone know how to call SOAP::Lite methods inside a Safe object?
> The attempt below fails for some reason:
What reason? What is it doing that you don't want it to do -or- what is
it not doing you do want it to do?
>
> #=====
> use strict;
> use warnings;
> use Safe;
> use SOAP::Lite;
>
> my $compartment = new Safe;
> my $retval;
> my $resource = '212';
> my $sl = new SOAP::Lite;
>
> my $code = <<SCODE;
> \$retval = \$sl
> -> uri('http://www.soaplite.com/Temperatures')
> -> proxy('http://services.soaplite.com/temper.cgi')
> -> f2c(\$resource)
> -> result;
> print "Result is \$retval\n";
> SCODE
>
> print "Now outside the box...";
> eval $code;
'eval', in general (a very general sense; OTOH, there are safe ways to use
'eval'), is not something safe. And, just at first glance, I don't really
understand why you're using 'eval' at all. As I'm not familiar with Safe,
is this something that's in the documentation that you're supposed to do?
In general, if you don't know why you're using 'eval', don't.
> $retval = undef;
> $compartment->share(qw($retval $resource $sl));
> $compartment->permit(qw(print));
Okay - you've just evaluated the coderef and now you're trying to make it
safe. Again, is this something in the documentation? This just doesn't
seem right :-)
> print "\n\nNow in the box...\n";
> $compartment->reval($code);
> #========
>
> Ideas?
See comments above and HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
If God didn't mean for us to juggle, tennis balls wouldn't come
three to a can.
------------------------------
Date: Sun, 07 Mar 2004 12:21:34 -0700
From: Bill <wherrera@lynxview.com>
Subject: Re: SOAP::Lite in a Safe ?
Message-Id: <vrSdnTXDEq_969bdRVn-jw@adelphia.com>
James Willmore wrote:
> On Sat, 06 Mar 2004 21:36:31 -0700, Bill wrote:
>
>
>>Anyone know how to call SOAP::Lite methods inside a Safe object?
>>The attempt below fails for some reason:
>
>
> What reason? What is it doing that you don't want it to do -or- what is
> it not doing you do want it to do?
>
It fails to connect to the server, or do anything at all, except
complain that $sl is not a valid argument to use for the call. A
namespace problem with Safe.pm, which calls open, pack, etc within
Safe::Lite, I know. I just don't know if I can use Safe with an object?
I tried Safe::Hole, but can't get it to work here either.
>
>>#=====
>>use strict;
>>use warnings;
>>use Safe;
>>use SOAP::Lite;
>>
>>my $compartment = new Safe;
>>my $retval;
>>my $resource = '212';
>>my $sl = new SOAP::Lite;
>>
>>my $code = <<SCODE;
>>\$retval = \$sl
>> -> uri('http://www.soaplite.com/Temperatures')
>> -> proxy('http://services.soaplite.com/temper.cgi')
>> -> f2c(\$resource)
>> -> result;
>>print "Result is \$retval\n";
>>SCODE
>>
>>print "Now outside the box...";
>>eval $code;
>
>
> 'eval', in general (a very general sense; OTOH, there are safe ways to use
> 'eval'), is not something safe. And, just at first glance, I don't really
> understand why you're using 'eval' at all. As I'm not familiar with Safe,
> is this something that's in the documentation that you're supposed to do?
I want to take an arbitrary, perhaps tainted SOAP call and make it safe
from the likes of SQL injection. (SOAP injection?) I was hoping not to
have to roll my own Safe::SOAP or SOAP::Safe but maybe I do?
>
> In general, if you don't know why you're using 'eval', don't.
>
Sorry if the question was not clear. I was using eval here to show that
eval works but Safe::reval does not. The Safe module uses a
namespace-modified vesion of eval called reval.
>
>>$retval = undef;
>>$compartment->share(qw($retval $resource $sl));
>>$compartment->permit(qw(print));
>
>
------------------------------
Date: Sun, 7 Mar 2004 19:26:55 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: SOAP::Lite in a Safe ?
Message-Id: <c2ft1v$jtr$2@wisteria.csv.warwick.ac.uk>
Bill <wherrera@lynxview.com> wrote:
>
> I want to take an arbitrary, perhaps tainted SOAP call and make it safe
> from the likes of SQL injection. (SOAP injection?) I was hoping not to
> have to roll my own Safe::SOAP or SOAP::Safe but maybe I do?
Where is this SOAP call coming from? I do not think that Safe is the
right way to go on this: you would be much better off if you can getting
the spec for the call in some simpler language and constructing the call
from that.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Sun, 7 Mar 2004 14:58:37 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: socket communication / callback
Message-Id: <c2fdat$9rb$1@wisteria.csv.warwick.ac.uk>
Hannes <remove_Hannes.Krueger@uibk.ac.at> wrote:
> Ben Morrow wrote:
> > Hannes <hanRnes.EkrueMger@OuibkV.ac.Eat> wrote:
> >>
> >> I'm wondering if it's possible to use sockets for the folloing purpose:
> >> A running process acts as a kind of server, sometimes it receives some
> >> data. The receiving should trigger some functions (some display update
> >> based on the new values received). While waiting, the process should be
> >> responsive to local user-interactions.
> >
> > The best way is to put the sockets into non-blocking mode and use an
> > event loop. If you are doing the display using Tk or Gtk then these
> > toolkits provide an event loop already; if not then there are systems on
> > CPAN such as POE and stem that provide pre-packaged event loops which
> > you may find helpful.
>
> Because I'm new to sockets I didn't really know about the non-blocking
> mode...
> Yes, I'm using perl/Tk. How would you use an event loop? Idle-Callback
> polling? Or is there a way to get a callback on incoming data (asynchronous
> notification - like in C via SIGIO...?)
See perldoc Tk::fileevent.
Ben
--
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks] ben@morrow.me.uk
------------------------------
Date: Sun, 07 Mar 2004 17:41:26 +0100
From: Hannes <remove_Hannes.Krueger@uibk.ac.at>
Subject: Re: socket communication / callback
Message-Id: <404b50e6@sia.uibk.ac.at>
Ben Morrow wrote:
>
> Hannes <remove_Hannes.Krueger@uibk.ac.at> wrote:
>> Ben Morrow wrote:
>> > Hannes <hanRnes.EkrueMger@OuibkV.ac.Eat> wrote:
>> >>
>> >> I'm wondering if it's possible to use sockets for the folloing
>> >> purpose: A running process acts as a kind of server, sometimes it
>> >> receives some data. The receiving should trigger some functions (some
>> >> display update based on the new values received). While waiting, the
>> >> process should be responsive to local user-interactions.
>> >
>> > The best way is to put the sockets into non-blocking mode and use an
>> > event loop. If you are doing the display using Tk or Gtk then these
>> > toolkits provide an event loop already; if not then there are systems
>> > on CPAN such as POE and stem that provide pre-packaged event loops
>> > which you may find helpful.
>>
>> Because I'm new to sockets I didn't really know about the non-blocking
>> mode...
>> Yes, I'm using perl/Tk. How would you use an event loop? Idle-Callback
>> polling? Or is there a way to get a callback on incoming data
>> (asynchronous notification - like in C via SIGIO...?)
>
> See perldoc Tk::fileevent.
>
> Ben
>
Of cause! That can be used for the socket-equivalent of an filehandle..
Didn't think that far... ;-)
Thanks for your help
------------------------------
Date: Sun, 7 Mar 2004 21:49:11 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: String Search containing a '/' character
Message-Id: <c2g5aj$bkh$1@newsg3.svr.pol.co.uk>
Basically I have a date, say 02/04, in a text file. I need to find that so
i've got
if ($line=~m/\d\d??\d\d/)
to find the 2 lots of digits (the date and month) but I can't work out how I
add the / in there (in place of the ??) I've tried a few things but nothing
is working?
--
Bumble
------------------------------
Date: 7 Mar 2004 22:16:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: String Search containing a '/' character
Message-Id: <c2g6vv$a4r$1@mamenchi.zrz.TU-Berlin.DE>
Bumble <bumble@what.the.heck> wrote in comp.lang.perl.misc:
> Basically I have a date, say 02/04, in a text file. I need to find that so
> i've got
>
> if ($line=~m/\d\d??\d\d/)
>
> to find the 2 lots of digits (the date and month) but I can't work out how I
> add the / in there (in place of the ??) I've tried a few things but nothing
> is working?
Did "a few things" include escaping the "/" with a backslash? That isn't
the best method, but it is certainly something to try, and it works.
It's better to use an alternative delimiter instead of "/". So both
"/\d\d\/\d\d/" and "m!\d\d/\d\d!" should work.
Anno
------------------------------
Date: Sun, 7 Mar 2004 22:06:29 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: String Search containing a '/' character
Message-Id: <c2g6av$kej$1@news.simnet.is>
"Bumble" <bumble@what.the.heck> wrote in message
news:c2g5aj$bkh$1@newsg3.svr.pol.co.uk...
> Basically I have a date, say 02/04, in a text file. I need to find that so
> i've got
>
> if ($line=~m/\d\d??\d\d/)
>
> to find the 2 lots of digits (the date and month) but I can't work out how
I
> add the / in there (in place of the ??) I've tried a few things but
nothing
> is working?
but have you tried reading the docs ?
perldoc perlre
gnari
------------------------------
Date: Sun, 07 Mar 2004 18:44:51 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: triggering callback from "outside"
Message-Id: <D4K2c.20977$Bh2.3521@newssvr29.news.prodigy.com>
Hannes wrote:
> Is there a way in Perl to get a callback triggered by incoming data?
> Keeping the process busy by polling the non-blocking socket in an
> idle-callback wouldn't be very good...
Why not? That's very similar to what Tk::MainLoop() is doing. You have
to poll to find something (unless you're using signals, but in your case
you can't).
For your purposes, I would replace the call to Tk::MainLoop with
something like the following [untested - adapted from example in perldoc
IO::Select]:
use Tk qw/:eventtypes/;
use IO::Select;
use IO::Socket;
my $lsn = new IO::Socket::INET(Listen => 1, LocalPort => 12345);
my $sel = new IO::Select($lsn);
while (1) { # this is your mainloop
# process any Tk events like mouse moves/button presses/etc
1 while $MW->DoOneEvent(ALL_EVENTS|DONT_WAIT);
# poll for any data in the sockets in a non-blocking way
if (my @ready = $sel->can_read(0.1)) {
for my $fh (@ready) {
if ($fh == $lsn) { # new connection
my $new = $lsn->accept;
$sel->add($new);
} else {
# somebody sent something
my $data = <$fh>;
if (defined $data) {
#
# trigger your callback based on what $data contains.
#
} else { # hung up
$sel->remove($fh);
$fh->close;
}
}
}
}
}
Now your clients can connect to port 12345 on the local machine and send
whatever data is needed to trigger the callbacks.
--Ala
------------------------------
Date: Sun, 7 Mar 2004 19:35:31 +0100
From: "Reto Hersiczky" <rhersiczky@cuthere-hotmail.com>
Subject: Re: using C++ from perl
Message-Id: <404b6b6c$0$717$5402220f@news.sunrise.ch>
The CPAN module "Inline" by Brian Ingerson is excellent for that.
It might be necessary to customize your C++ classes so they
work together wth Inline.
There is a German article available about this issue on
http://www.linux-magazin.de/Artikel/ausgabe/2003/02/perl/perl.html
"C-Funktionen in Perl mit dem Inline-Modul"
As far as I know, this Module has even won an award. You can
re-assemble any compiled language in your Perl Module, not only
C/C++. The Inline module checks the MD5 fingerprint of the related
code section and calls the precompiled code if there are no changes.
When changes are made, the Inline module automatically recompiles
the code section (all the dirty work). All you'd notice would be a
one-time delay for the compilation time.
--retoh :)
"Bryan Krone" <bryan.krone@motorola.com> wrote in message
news:4047448E.81FC1862@motorola.com...
> Sergei Emantayev wrote:
> >
> > Hello, dear all!
> > My question is about using C++ classes from Perl.
> > Is it possible to create and manage c++ objects in perl?
> > Is there any helper libraries like boost.python?
>
> Inline::CPP
------------------------------
Date: Sun, 7 Mar 2004 19:59:36 +0100
From: "Mark" <admin@asarian-host.net>
Subject: What could cause Time::Hires to fail?
Message-Id: <HrydncisOJyG7NbdRVn-jA@giganews.com>
This is weird. I just tried to install Perl 5.8.2_5 on a clean FreeBSD 4.9R
box (via ports), and got an error on Time::Hires. I grabbed the package
manually, and got the same error:
PERL_DL_NONLAZY=1 /usr/local/perl-threaded/bin/perl
"-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')"
t/*.t
t/HiRes....ok 18/25
t/HiRes.t: overall time allowed for tests (60s) exceeded
t/HiRes....dubious
Test returned status 0 (wstat 15, 0xf)
DIED. FAILED tests 19-25
Failed 7/25 tests, 72.00% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
--------------------------------------------------------------------------
t/HiRes.t 0 15 25 14 56.00% 19-25
Failed 1/1 test scripts, 0.00% okay. 7/25 subtests failed, 72.00% okay.
*** Error code 2
What could cause Time::Hires to fail?
Does Hires use a math co-processor? The only difference to the kernel I ran
yesterday, is that I commented out this;
# options MATH_EMULATE
On an AMD XP-2200; as I take it it has the co-processor. Still, could that
be what is cause Hires to fail?
Thanks,
- Mark
------------------------------
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 6230
***************************************