[31498] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2757 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 7 14:09:44 2010

Date: Thu, 7 Jan 2010 11:09:11 -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           Thu, 7 Jan 2010     Volume: 11 Number: 2757

Today's topics:
        converting from 'use' to 'require' <john1949@yahoo.com>
    Re: converting from 'use' to 'require' <bugbear@trim_papermule.co.uk_trim>
    Re: converting from 'use' to 'require' <derykus@gmail.com>
    Re: converting from 'use' to 'require' <bugbear@trim_papermule.co.uk_trim>
    Re: converting from 'use' to 'require' <uri@StemSystems.com>
    Re: converting from 'use' to 'require' <jurgenex@hotmail.com>
    Re: FAQ 7.10 How do I adopt or take over a module alrea <brian.d.foy@gmail.com>
    Re: FAQ 7.10 How do I adopt or take over a module alrea <spamtrap@shermpendley.com>
    Re: LWP::UserAgent HTTP POST authentication problem <graham.stow@stowassocs.co.uk>
    Re: LWP::UserAgent HTTP POST authentication problem <derykus@gmail.com>
    Re: LWP::UserAgent HTTP POST authentication problem <graham.stow@stowassocs.co.uk>
    Re: LWP::UserAgent HTTP POST authentication problem <graham.stow@stowassocs.co.uk>
    Re: LWP::UserAgent HTTP POST authentication problem <derykus@gmail.com>
    Re: Perl DBI module hanging (transaction isolation) <OJZGSRPBZVCX@spammotel.com>
        Regex to extract email from .msg <bart@nijlen.com>
    Re: Regex to extract email from .msg <hjp-usenet2@hjp.at>
    Re: significant figures <OJZGSRPBZVCX@spammotel.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 7 Jan 2010 11:32:08 -0000
From: "John" <john1949@yahoo.com>
Subject: converting from 'use' to 'require'
Message-Id: <hi4gnm$f2m$1@news.albasani.net>

Just checking I'm doing the right thing.

I have a main program (main.pl) and several libraries (LIB1.pm LIBmatrix.pm 
LIBgraph.pm) each containing about 50 routines.

I begin:

use warnings;
use strict;
use LIB1;
use LIBmatrix;
use LIBgraph;

There are many options for the user, but no user ever uses all the routines. 
The problem is that  'use' will load all the routines when main.pl is 
invoked.
As the program has grown I am aware that when main.pl is invoked it is taken 
quite a long time to load.

My solution would be to use 'require'.  Change LIB.pm to LIB.pl and access 
via:

require 'LIB1.pl';
my $x=LIB1::curve($z,$w);

Am I right in thinking that memory usage will fall and loading will be 
faster as I only access the routines when requested by the user?

Regards
John







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

Date: Thu, 07 Jan 2010 12:25:47 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: converting from 'use' to 'require'
Message-Id: <T_ydnVPLCrNBT9jWnZ2dnUVZ8lqdnZ2d@brightview.co.uk>

John wrote:
> Just checking I'm doing the right thing.
> 
> I have a main program (main.pl) and several libraries (LIB1.pm LIBmatrix.pm 
> LIBgraph.pm) each containing about 50 routines.
> 
> I begin:
> 
> use warnings;
> use strict;
> use LIB1;
> use LIBmatrix;
> use LIBgraph;
> 
> There are many options for the user, but no user ever uses all the routines. 
> The problem is that  'use' will load all the routines when main.pl is 
> invoked.
> As the program has grown I am aware that when main.pl is invoked it is taken 
> quite a long time to load.
> 
> My solution would be to use 'require'.  Change LIB.pm to LIB.pl and access 
> via:
> 
> require 'LIB1.pl';
> my $x=LIB1::curve($z,$w);
> 
> Am I right in thinking that memory usage will fall and loading will be 
> faster as I only access the routines when requested by the user?

No; check what require does, and check what "use" does.

For what you suggest to be helpful, perl would have to defer
compilation/loading of the routine until first use - and somehow
find the function on first use.

You probably want to look at CPAN - AutoSplit and AutoLoader.

    BugBear


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

Date: Thu, 7 Jan 2010 06:00:43 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: converting from 'use' to 'require'
Message-Id: <1d70f026-9667-4278-ba91-385b070a3f9c@u7g2000yqm.googlegroups.com>

On Jan 7, 3:32=A0am, "John" <john1...@yahoo.com> wrote:
> Just checking I'm doing the right thing.
>
> I have a main program (main.pl) and several libraries (LIB1.pm LIBmatrix.=
pm
> LIBgraph.pm) each containing about 50 routines.
>
> I begin:
>
> use warnings;
> use strict;
> use LIB1;
> use LIBmatrix;
> use LIBgraph;
>
> There are many options for the user, but no user ever uses all the routin=
es.
> The problem is that =A0'use' will load all the routines when main.pl is
> invoked.
> As the program has grown I am aware that when main.pl is invoked it is ta=
ken
> quite a long time to load.
>
> My solution would be to use 'require'. =A0Change LIB.pm to LIB.pl and acc=
ess
> via:
>
> require 'LIB1.pl';
> my $x=3DLIB1::curve($z,$w);
>
> Am I right in thinking that memory usage will fall and loading will be
> faster as I only access the routines when requested by the user?
>

perldoc autouse


NAME
    autouse - postpone load of modules until a function is used


SYNOPSIS
      use autouse 'Carp' =3D> qw(carp croak);
      carp "this carp was predeclared and autoused ";
 ...

--
Charles DeRykus



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

Date: Thu, 07 Jan 2010 16:37:25 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: converting from 'use' to 'require'
Message-Id: <VsmdnQX2_MhYkNvWnZ2dnUVZ8o1i4p2d@brightview.co.uk>

Shmuel (Seymour J.) Metz wrote:
> In <T_ydnVPLCrNBT9jWnZ2dnUVZ8lqdnZ2d@brightview.co.uk>, on 01/07/2010
>    at 12:25 PM, bugbear <bugbear@trim_papermule.co.uk_trim> said:
> 
>> No; check what require does, and check what "use" does.
> 
> Yes; check what eval does. What the OP requested is possible; whether it
> is a good idea is open to discussion.
> 

Surely both use and require read-and-parse the file, differing
only in wether symbols are imported?

How does changing from "use" to "require" speed anything up
(unless import is a lot slower than I thought)

   BugBear


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

Date: Thu, 07 Jan 2010 13:21:24 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: converting from 'use' to 'require'
Message-Id: <87k4vtbwt7.fsf@quad.sysarch.com>

>>>>> "b" == bugbear  <bugbear@trim_papermule.co.uk_trim> writes:

  b> Shmuel (Seymour J.) Metz wrote:
  >> In <T_ydnVPLCrNBT9jWnZ2dnUVZ8lqdnZ2d@brightview.co.uk>, on 01/07/2010
  >> at 12:25 PM, bugbear <bugbear@trim_papermule.co.uk_trim> said:
  >> 
  >>> No; check what require does, and check what "use" does.
  >> 
  >> Yes; check what eval does. What the OP requested is possible; whether it
  >> is a good idea is open to discussion.
  >> 

  b> Surely both use and require read-and-parse the file, differing
  b> only in wether symbols are imported?

  b> How does changing from "use" to "require" speed anything up
  b> (unless import is a lot slower than I thought)

require is done at run time but use is at compile time. so if you want
to only load some code when you want it, require works for that. use
would load all the code no matter what. but you do need to handle how to
load code on demand. the autouse module does that as someone else
posted. i bet it puts in trampoline subs which when get called will load
the needed modules and then goto the real sub which should now have
replaced it in the symbol table.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 07 Jan 2010 10:24:14 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: converting from 'use' to 'require'
Message-Id: <5c9ck5thr40ichcqijjp19t6hue0og47fn@4ax.com>

bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
>Shmuel (Seymour J.) Metz wrote:
>> In <T_ydnVPLCrNBT9jWnZ2dnUVZ8lqdnZ2d@brightview.co.uk>, on 01/07/2010
>>    at 12:25 PM, bugbear <bugbear@trim_papermule.co.uk_trim> said:
>> 
>>> No; check what require does, and check what "use" does.
>> 
>> Yes; check what eval does. What the OP requested is possible; whether it
>> is a good idea is open to discussion.
>> 
>
>Surely both use and require read-and-parse the file, differing
>only in wether symbols are imported?
>
>How does changing from "use" to "require" speed anything up
>(unless import is a lot slower than I thought)

Simple. Because use() is executed at compile time there is no way _NOT_
to execute it. require() on the other hand is executed at runtime,
Therefore it is possible to control its execution with standard flow
control commands, e.g.

	if ($debug) {
		require MyDebugFunctions;}

Unless $debug is true there is nothing being loaded or executed.

jue


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

Date: Thu, 07 Jan 2010 13:42:22 +0100
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 7.10 How do I adopt or take over a module already on CPAN?
Message-Id: <070120101342224356%brian.d.foy@gmail.com>

In article <slrnhkavi6.7re.nospam-abuse@powdermilk.math.berkeley.edu>,
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:

> On 2010-01-06, PerlFAQ Server <brian@theperlreview.com> wrote:
> > 7.10: How do I adopt or take over a module already on CPAN?


> Nowadays there is an alternative (but more cumbersome) way to improve
> someone else's modules: maintain patches as a part of your own
> `bundle', so that people can use CPAN.pm's auto-patching abilities.

There's also my stuff that let's you maintain your own CPAN, or the
MiniCPAN stuff that lets you insert anything that you like.  Those are
a bit out of scope for the question though.

The patching stuff does look interesting though :)


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

Date: Thu, 07 Jan 2010 12:35:46 -0500
From: Sherm Pendley <spamtrap@shermpendley.com>
Subject: Re: FAQ 7.10 How do I adopt or take over a module already on CPAN?
Message-Id: <m2d41l95sd.fsf@shermpendley.com>

Tad McClellan <tadmc@seesig.invalid> writes:

> Uri Guttman <uri@StemSystems.com> wrote:
>>>>>>> "SP" == Sherm Pendley <pshendley@gmail.com> writes:
>                               ^^
>                               ^^
>>  SP> On Jan 6, 11:00 am, PerlFAQ Server <br...@theperlreview.com> wrote:
>>
>>  >> If you'd like to help maintain the perlfaq, see the details in
>>  >> perlfaq.pod.
>>
>>  SP> Send this Republican nonsense elsewhere.
>>
>> huh??
>
> My guess is that this poster is not the real Sherm.
>
> Most of his recent posts where from spamtrap@shermpendley.com.
>
> We are being trolled.

Exactly. I've shut down six or seven fake Facebook profiles that his
guy created too.

Somebody needs to get a f**king life...

sherm--


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

Date: Thu, 7 Jan 2010 12:27:03 -0000
From: "Graham" <graham.stow@stowassocs.co.uk>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <A9adndgzPe-DTtjWnZ2dnUVZ8jydnZ2d@bt.com>

This is awfully embarassing, but the reason for the 'length required' error 
appears to be that no data is being sent from the Nochex servers (obviously 
I should have checked that first before bothering folk). Why this is 
happening (or rather not happening) I can't imagine - I'm querying this with 
Nochex, but they just don't answer the support queries. 




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

Date: Thu, 7 Jan 2010 06:53:23 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <88a2c951-be00-4183-834f-2e5f2fbe3d0b@r24g2000yqd.googlegroups.com>

On Jan 7, 1:46=A0am, "Graham" <graham.s...@stowassocs.co.uk> wrote:
> "C.DeRykus" <dery...@gmail.com> wrote in message
>

> > ...
>
>
> I've added '$status =3D $res->status;' line where suggested, and have als=
o
> added the lines '$response_as_string =3D $res->as_string;' and '$error_as=
_html
> =3D $res->error_as_HTML;'. When I print these, I get the following output=
:-
> ----------------------------------------------------------------------
> response_as_string =3D HTTP/1.1 411 Length Required
> ...
> status =3D 411 Length
> Required-----------------------------------------------So it appears that=
 a
> length is required. It may be a stupid question, but a length of what, an=
d
> how should I provide it within the following code?use LWP::UserAgent;$ua =
=3D
> new LWP::UserAgent;$req =3D new HTTP::Request('POST',
> 'https://www.nochex.com/nochex.dll/apc/apc');$req->content_type("applicat=
ion/x-www-form-urlencoded");$req->content($query);$res
> =3D $ua->request($req);


A POST will require a valid content-length header IIRC.

  > $req->content($query);
  > $res =3D $ua->request($req);

Where is your request $query above defined?

You can check the actual request to ensure that the
request has valid headers and the $query content is
getting set and passed to the server correctly.

    print $req->as_string;

As mentioned earlier, 'use LWP::Debug qw/+/' will provide
voluminous details about the transaction too.


--
Charles DeRykus


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

Date: Thu, 7 Jan 2010 17:39:28 -0000
From: "Graham" <graham.stow@stowassocs.co.uk>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <noednf5LtvDJgdvWnZ2dnUVZ7vmdnZ2d@bt.com>


"C.DeRykus" <derykus@gmail.com> wrote in message 
news:88a2c951-be00-4183-834f-2e5f2fbe3d0b@r24g2000yqd.googlegroups.com...
On Jan 7, 1:46 am, "Graham" <graham.s...@stowassocs.co.uk> wrote:
> "C.DeRykus" <dery...@gmail.com> wrote in message
>

> > ...
>
>
> I've added '$status = $res->status;' line where suggested, and have also
> added the lines '$response_as_string = $res->as_string;' and 
> '$error_as_html
> = $res->error_as_HTML;'. When I print these, I get the following output:-
> ----------------------------------------------------------------------
> response_as_string = HTTP/1.1 411 Length Required
> ...
> status = 411 Length
> Required-----------------------------------------------So it appears that 
> a
> length is required. It may be a stupid question, but a length of what, and
> how should I provide it within the following code?use LWP::UserAgent;$ua =
> new LWP::UserAgent;$req = new HTTP::Request('POST',
> 'https://www.nochex.com/nochex.dll/apc/apc');$req->content_type("application/x-www-form-urlencoded");$req->content($query);$res
> = $ua->request($req);


A POST will require a valid content-length header IIRC.

  > $req->content($query);
  > $res = $ua->request($req);

Where is your request $query above defined?

$query is defined in the following line near the top of the script:-
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});

You can check the actual request to ensure that the
request has valid headers and the $query content is
getting set and passed to the server correctly.

    print $req->as_string;

adding the following lines:-

$request_as_string = $req->as_string;
print "request_as_string = $request_as_string\n";

produced the following output:-

'request_as_string = POST https://www.nochex.com/nochex.dll/apc/apc
User-Agent: libwww-perl/5.79
Content-Type: application/x-www-form-urlencoded'Notably, there is no mention 
of any $query content, so I guess there isn't any! However, is that because 
none is being provided in the call-back, or am I just not finding it 
somehow?As mentioned earlier, 'use LWP::Debug qw/+/' will providevoluminous 
details about the transaction too.Unfortunately, the CPAN write up on 
LWP::Debug doesn't give me enough information to figure out how to apply 
it.--Charles DeRykus 




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

Date: Thu, 7 Jan 2010 17:47:39 -0000
From: "Graham" <graham.stow@stowassocs.co.uk>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <dfednXJVHf3dg9vWnZ2dnUVZ8nydnZ2d@bt.com>


"Sherm Pendley" <pshendley@gmail.com> wrote in message 
news:5a663d9b-dc49-4cde-bc1d-558320d5446a@m3g2000yqf.googlegroups.com...
On Jan 6, 12:04 pm, "Graham" <graham.s...@stowassocs.co.uk> wrote:
> Below is a suggested 'Automatic Payment Confirmation' script copied and
> pasted from the Nochex Developer's forum (Nochex themselves do not offer
> support in Perl). This thread is now closed and I suspect the Nochex forum
> does not get much traffic, hence this post here. I have spotted one error
> (the line '$mail_method = "sendmail";' needs to be added if using 
> sendmail).
> However, even with this correction, the script always goes down the first 
> of
> the four 'if (res->' options (i.e. (res->is_error)), and thus none of my
> test transactions are being authorised, which makes me suspect that there 
> is
> something wrong with the following lines:-
>
> use LWP::UserAgent;
> $ua = new LWP::UserAgent;
> $req = new HTTP::Request 
> "POST","https://www.nochex.com/nochex.dll/apc/apc";
> $req->content_type("application/x-www-form-urlencoded");
> $req->content($query);
> $res = $ua->request($req);
>
> Anyone any ideas?
>
> #!/usr/bin/perl
>
> # REPLACE THIS WITH YOUR NOCHEX EMAIL ADDRESS.
> $admin_email = "sa...@geodetech.com";
>
> # THIS SHOULD BE EITHER smtp OR sendmail DEPENDING
> # ON THE MAIL METHOD YOU WANT TO USE.
> $mail_method = "smtp";
>
> # IF YOU ARE USING SENDMAIL TO SEND EMAIL
> # SET THE PATH TO SENDMAIL ON YOUR SERVER.
> # IN ALL PROBABILITY THE DEFAULT WILL WORK
> $sendmail_path = "/usr/sbin/sendmail -t";
>
> # IF YOU ARE USING SMTP TO SEND EMAIL
> # SPECIFY THE SMTP SERVER TO USE.
> # IN ALL PROBABILITY THE DEFAULT WILL WORK
> $smtp_server = "localhost";
>
> read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
>
> @pairs = split(/&/, $query);
> $count = 0;
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $variable{$name} = $value;
> $count++;
>
> }
>
> $transaction_id = $variable{'transaction_id'};
> $transaction_date = $variable{'transaction_date'};
> $from_email = $variable{'from_email'};
> $to_email = $variable{'to_email'};
> $order_id = $variable{'order_id'};
> $amount = $variable{'amount'};
> $security_key = $variable{'security_key'};
>
> use LWP::UserAgent;
> $ua = new LWP::UserAgent;
> $req = new HTTP::Request 
> "POST","https://www.nochex.com/nochex.dll/apc/apc";
> $req->content_type("application/x-www-form-urlencoded");
> $req->content($query);
> $res = $ua->request($req);
>
> if ($res->is_error) {
> $subject = "Perl APC Script Error - Could not connect to Nochex servers";
> $message = "Your Perl APC script was called but returned an error because
> it \ncould not connect with the NOCHEX servers.\n.";} elsif ($res->content 
> eq "AUTHORISED") {
>
> $subject = "APC Result - AUTHORISED";
> $message = "NOCHEX RESPONSE:
> AUTHORISED\n-----------------------------------------------\nOrder 
> submitted
> with ID:
> ".$order_id."\n-----------------------------------------------\ntransaction
> id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfrom
> email:\t".$from_email."\nto
> email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\nsecu 
> rity
> key:\t".$security_key."\n";} elsif ($res->content eq "DECLINED") {
>
> $subject = "APC Result - DECLINED";
> $message = "NOCHEX RESPONSE:
> DECLINED\n-----------------------------------------------\nOrder submitted
> with ID:
> ".$order_id."\n-----------------------------------------------\ntransaction
> id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfrom
> email:\t".$from_email."\nto
> email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\nsecu 
> rity
> key:\t".$security_key."\n";} else {
>
> $subject = "Invalid APC Result Returned";
> $message = "The NOCHEX APC server returned an unrecognised or invalid
> response. In \nall probability due to en error in your code but could be 
> the
> APC \nserver screwing
> up.\n-----------------------------------------------\nOrder submitted with
> ID:
> ".$order_id."\n-----------------------------------------------\ntransaction
> id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfrom
> email:\t".$from_email."\nto
> email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\nsecu 
> rity
> key:\t".$security_key."\n";
>
> }
>
> print "Content-Type: text/plain\n\n";
>
> if ($mail_method eq "smtp") {
> use Net::SMTP;
> $smtp = Net::SMTP->new($smtp_server);
> $smtp->mail($ENV{USER});
> $smtp->to($admin_email);
> $smtp->data();
> $smtp->datasend("From: APC Script <apc_scr...@your.website>\n");
> $smtp->datasend("To: ".$admin_email."\n");
> $smtp->datasend("Subject: ".$admin_email."\n");
> $smtp->datasend("Content-Type: text/plain\n");
> $smtp->datasend("\n");
> $smtp->datasend($message);
> $smtp->dataend();
> $smtp->quit;} elsif ($mail_method eq "sendmail") {
>
> open(SENDMAIL, "|$sendmail_path") or die "Cannot open sendmail: $!";
> print SENDMAIL "From: APC Script <apc_scr...@your.website>\n";
> print SENDMAIL "To: ".$admin_email."\n";
> print SENDMAIL "Subject: ".$subject."\n";
> print SENDMAIL "Content-Type: text/plain\n\n";
> print SENDMAIL $message;
> close(SENDMAIL);
>
>
>
> }

Why did you post this here? Seems to me *someone* forgot what groups
are for what! ;)

sherm--

I explained why at the top of the post! This is the number one newsgroup for 
miscellaneous perl discussions and queries and, as far as I'm concerned, I'm 
bang on topic. Also, it appears Charles DeRykus agrees with me, and he's 
being VERY helpful.

Graham 




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

Date: Thu, 7 Jan 2010 10:41:16 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <00278b64-a0f5-4042-8ae8-e1b1f3124adb@v25g2000yqk.googlegroups.com>

On Jan 7, 9:39=A0am, "Graham" <graham.s...@stowassocs.co.uk> wrote:
> ...
>
> A POST will require a valid content-length header IIRC.
>
> =A0 > $req->content($query);
> =A0 > $res =3D $ua->request($req);
>
> Where is your request $query above defined?
>
> $query is defined in the following line near the top of the script:-
> read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
>
> You can check the actual request to ensure that the
> request has valid headers and the $query content is
> getting set and passed to the server correctly.
>
> =A0 =A0 print $req->as_string;
>
> adding the following lines:-
>
> $request_as_string =3D $req->as_string;
> print "request_as_string =3D $request_as_string\n";
>
> produced the following output:-
>
> 'request_as_string =3D POSThttps://www.nochex.com/nochex.dll/apc/apc
> User-Agent: libwww-perl/5.79
> Content-Type: application/x-www-form-urlencoded'Notably, there is no ment=
ion
> of any $query content, so I guess there isn't any! However, is that becau=
se
> none is being provided in the call-back, or am I just not finding it
> somehow?

There's a major problem then because you're sending no content
in the POST.  The code you posted shows:

  read (STDIN, $query, $ENV{'CONTENT_LENGTH'});

So the intent is to pick up the correct form pairs from the
user  via STDIN to supply the POST content. Adding this check
would be a good idea:

my $len =3D read( STDIN, $query, $ENV{'CONTENT_LENGTH'})
  or die "error: ", defined $len ? "no content" : $!;


As mentioned earlier, 'use LWP::Debug qw/+/' will providevoluminous
> details about the transaction too.Unfortunately, the CPAN write up on
> LWP::Debug doesn't give me enough information to figure out how to apply
> it.

It's applied automatically if added as is.

(This thread is probably better continued in the
 libwww-perl mailing list. Check Google for details.)

--
Charles DeRykus


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

Date: Thu, 07 Jan 2010 17:46:45 +0100
From: "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>
Subject: Re: Perl DBI module hanging (transaction isolation)
Message-Id: <op.u558v7gimk9oye@frodo>

(Sorry for the bad quote, don't have the previous message.)

On Thu, 07 Jan 2010 04:12:42 +0100, Xho Jingleheimerschmidt  
<xhoster@gmail.com> wrote:

> dn.perl@gmail.com wrote:
>> I am running a perl script (on ancient Perl 5.6, with which I am
>> stuck) which uses DBI module. The script runs  select, delete and
>> insert statements against an Oracle table. The script runs properly
>> most of the time.

As long as you do not need CPAN modules which require 5.8 or newer, and as  
long as you do not work with Unicode, perl 5.6 is fine, especially  
together with Oracle.

This finished the perl specific part of the question, nevertheless:

>>  Case B)
>> In sqlplus session, I delete all the 5 records from the table but do
>> not run commit.
>> Then I run the perl script but it hangs.
>> I issue 'commit' via sqlplus, and the 'hanging' perl script starts
>> running at once.
>>  I do not want my perl script to hang.

No, it does not hang. It merely waits on a lock (hard to tell which one  
without knowing what your perl script does; if you need to know, then  
Google will quickly turn up SQL queries you can use to find out which  
particular kind of lock it is).

Oracle is extremely robust in respect to "hanging" - it usually  
automatically and immediately detects real hangs (deadlocks) and aborts  
one of the involved transactions with an error.

The only kind of "hanging" you will experience is the one you have found:  
one transaction is being kept open (i.e., neither a rollback or a commit  
happens), and while it does, it can hold certain locks. Although in  
Oracle, you're lucky in that there are only very few occasions where you  
actually have to wait on another transaction. It would be interesting to  
know what exactly your perl script is trying to do.

>> Is it possible to set a
>> transaction isolation level via DBI (perhaps immediately after
>> connecting to the database  DBI->connect) which will enable the perl
>> script to run smoothly even when I have deleted some records in the
>> sqlplus session without commiting the delete action.

It does not make sense to ask the question like this. The answer to this  
particular question is "no" simply because there is no way in Oracle to  
influence locking/transaction behaviour in regard to a particular DML  
statement (i.e., specific for DELETE).

And on another level, the answer is also "no", because there *is* a reason  
why Oracle locks there. Oracle is not like other DBs that lock everything  
"just in case"; if locks do happen, there is a good reason, and usually by  
avoiding the lock, you are not doing yourself a favour at all.

> Maybe you can set autocommit to on in sqlplus.

 ... but be sure to understand what it does (towards the original poster).  
It *will* get rid of your current problem, but maybe not in the way you  
want/expect to, and it can burn you later.

> But why you have a burning desire to achieve data corruption is beyond  
> me.  Maybe you can switch to a database that specializes in corrupting  
> your data.

ACK.


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

Date: Thu, 7 Jan 2010 09:19:40 -0800 (PST)
From: Bart Van der Donck <bart@nijlen.com>
Subject: Regex to extract email from .msg
Message-Id: <a9ebab2c-1bdb-4a59-a241-3f7a7601deed@m26g2000yqb.googlegroups.com>

Hello,

I have been assigned a task to filter out an email address from the
body of a (.msg) source file.

The source file looks odd and displays differently in various
plaintext readers. It looks like some sort of half binary / half ascii
format (including the headers). The body of the file is more-or-less
consistent. The address to be extracted is in the following format:

   "-   n a m e @ h o s t . c o m   "

All text in the source file is with such spaces between.

Spaces can be displayed like EOL, space or nothing. Binary characters
seem to be inserted randomly; sometimes I can recognize a pattern of a
repeated string. Maybe someone is familiar with this format ? The
messages were saved from MS Outlook.

I tried many variants, my best shot goes to:

   if (/(-)(\s\s\s)(.+)(@)(.+)(\.)(.+)(\s\s\s)/gs)  { ...

But still no success. I was thinking of an encoding issue (Unicode/
UTF?), but the source file seems too different for that.

Thanks

--
 Bart


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

Date: Thu, 7 Jan 2010 20:00:36 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Regex to extract email from .msg
Message-Id: <slrnhkcbql.jvd.hjp-usenet2@hrunkner.hjp.at>

On 2010-01-07 17:19, Bart Van der Donck <bart@nijlen.com> wrote:
> I have been assigned a task to filter out an email address from the
> body of a (.msg) source file.
>
> The source file looks odd and displays differently in various
> plaintext readers. It looks like some sort of half binary / half ascii
> format (including the headers). The body of the file is more-or-less
> consistent. The address to be extracted is in the following format:
>
>    "-   n a m e @ h o s t . c o m   "
>
> All text in the source file is with such spaces between.
>
> Spaces can be displayed like EOL, space or nothing.

Then they probably aren't spaces. Most likely they are nul characters.
If you have Linux, use hd (or od) to look at the file. If you use
Windows, there's probably some freeware hex editor/viewer you can use.

> But still no success. I was thinking of an encoding issue (Unicode/
> UTF?), but the source file seems too different for that.

Most likely UTF-16, but there may be some additional markup.

	hp


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

Date: Thu, 07 Jan 2010 18:01:52 +0100
From: "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>
Subject: Re: significant figures
Message-Id: <op.u559le0rmk9oye@frodo>

On Wed, 06 Jan 2010 21:52:51 +0100, John Stanley <stanley@peak.org> wrote:

> $number = sprintf("%d", $number); # just in case ...
> return $number if $sigfigs > length($number);
>
> shows an even more amazing lack of understanding of significant figures.  
> It would return "1" for sigfigs 4, 1.234, which is patently absurd.

That would be me.

I'm sorry, English is not my primary language. I was not aware that  
"significant figure" has a particular meaning (and yes, Google shows it  
immediately), so misinterpreted his question. I thought his method was  
just for integer numbers, i.e. sigfigs(4,123456)=123400 etc..


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2757
***************************************


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