[31499] in Perl-Users-Digest
Perl-Users Digest, Issue: 2758 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 7 21:09:50 2010
Date: Thu, 7 Jan 2010 18:09:10 -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: 2758
Today's topics:
Re: converting from 'use' to 'require' <sysadmin@example.com>
Re: FAQ 7.10 How do I adopt or take over a module alrea <spamtrap@shermpendley.com>
Re: FAQ 7.10 How do I adopt or take over a module alrea <sysadmin@example.com>
Re: FAQ 7.10 How do I adopt or take over a module alrea <sysadmin@example.com>
Re: LWP::UserAgent HTTP POST authentication problem <pshendley@gmail.com>
Re: LWP::UserAgent HTTP POST authentication problem <sysadmin@example.com>
Re: perl in BartPE: locale warning <nospam-abuse@ilyaz.org>
Re: perl in BartPE: locale warning <ben@morrow.me.uk>
Re: Regex to extract email from .msg <smallpond@juno.com>
Re: Regex to extract email from .msg <sysadmin@example.com>
Re: Regex to extract email from .msg <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 07 Jan 2010 16:26:25 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: converting from 'use' to 'require'
Message-Id: <SYu1n.3033$Kq7.3020@newsfe04.iad>
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?
>
> Regards
> John
To be clear, with use, you can export/import the routines you want to
use (or only use), it doesn't have to be everything. Or, do you mean
loading a module altogether that won't be used at all? Do you mean
unused routines in a module, or unused modules?
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 07 Jan 2010 14:56:11 -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: <m23a2h665g.fsf@shermpendley.com>
Sherm Pendley <pshendley@gmail.com> writes:
> Send this Republican nonsense elsewhere.
Following me to usenet was a mistake Baxter - it gave me your IP
address. I've reported your behavior to Cox Internet. An internet
argument is one thing, but following me from service to service is
stalking, and it's a crime. If you stop now, I won't file charges.
Seriously dude - quit while you're ahead. You have no idea who you're
f**king with here.
sherm--
------------------------------
Date: Thu, 07 Jan 2010 16:29:56 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: FAQ 7.10 How do I adopt or take over a module already on CPAN?
Message-Id: <80v1n.3034$Kq7.1559@newsfe04.iad>
Sherm Pendley wrote:
> Sherm Pendley <pshendley@gmail.com> writes:
>
>> Send this Republican nonsense elsewhere.
>
> Following me to usenet was a mistake Baxter - it gave me your IP
> address. I've reported your behavior to Cox Internet. An internet
> argument is one thing, but following me from service to service is
> stalking, and it's a crime. If you stop now, I won't file charges.
>
> Seriously dude - quit while you're ahead. You have no idea who you're
> f**king with here.
>
> sherm--
While it's wrong, and annoying of them to do that, it's unlikely to be a
crime, unless this is just part of their actions that are crimes that
could add to proving harassment. I'm just saying, it's better to
ignore them/not respond to the abuse, than it is to engage and start
saying they're being reported and it's a crime. I doubt their ISP will
care what username they post as on usenet/who they pretend to be. I'm
sure they know this, so the above is likely only going to encourage
them to step it up, so to speak. Don't give them the satisfaction.
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 07 Jan 2010 16:30:49 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: FAQ 7.10 How do I adopt or take over a module already on CPAN?
Message-Id: <Z0v1n.3035$Kq7.627@newsfe04.iad>
Sherm Pendley wrote:
> Somebody needs to get a f**king life...
>
Now you're talking about 50% of the people online... :-) Anyway, don't
give the person the satisfaction of getting worked up, if you can help
it, because it'll only make it worse.
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 7 Jan 2010 15:37:30 -0800 (PST)
From: Permostat <pshendley@gmail.com>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <6920fe1f-2280-4179-b6f8-5ceaff209460@22g2000yqr.googlegroups.com>
On Jan 7, 11:47=A0am, "Graham" <graham.s...@stowassocs.co.uk> wrote:
> "Sherm Pendley" <pshend...@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 offe=
r
> > support in Perl). This thread is now closed and I suspect the Nochex fo=
rum
> > does not get much traffic, hence this post here. I have spotted one err=
or
> > (the line '$mail_method =3D "sendmail";' needs to be added if using
> > sendmail).
> > However, even with this correction, the script always goes down the fir=
st
> > of
> > the four 'if (res->' options (i.e. (res->is_error)), and thus none of m=
y
> > test transactions are being authorised, which makes me suspect that the=
re
> > is
> > something wrong with the following lines:-
>
> > 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("application/x-www-form-urlencoded");
> > $req->content($query);
> > $res =3D $ua->request($req);
>
> > Anyone any ideas?
>
> > #!/usr/bin/perl
>
> > # REPLACE THIS WITH YOUR NOCHEX EMAIL ADDRESS.
> > $admin_email =3D "sa...@geodetech.com";
>
> > # THIS SHOULD BE EITHER smtp OR sendmail DEPENDING
> > # ON THE MAIL METHOD YOU WANT TO USE.
> > $mail_method =3D "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 =3D "/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 =3D "localhost";
>
> > read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
>
> > @pairs =3D split(/&/, $query);
> > $count =3D 0;
> > foreach $pair (@pairs) {
> > ($name, $value) =3D split(/=3D/, $pair);
> > $value =3D~ tr/+/ /;
> > $value =3D~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> > $variable{$name} =3D $value;
> > $count++;
>
> > }
>
> > $transaction_id =3D $variable{'transaction_id'};
> > $transaction_date =3D $variable{'transaction_date'};
> > $from_email =3D $variable{'from_email'};
> > $to_email =3D $variable{'to_email'};
> > $order_id =3D $variable{'order_id'};
> > $amount =3D $variable{'amount'};
> > $security_key =3D $variable{'security_key'};
>
> > 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("application/x-www-form-urlencoded");
> > $req->content($query);
> > $res =3D $ua->request($req);
>
> > if ($res->is_error) {
> > $subject =3D "Perl APC Script Error - Could not connect to Nochex serve=
rs";
> > $message =3D "Your Perl APC script was called but returned an error bec=
ause
> > it \ncould not connect with the NOCHEX servers.\n.";} elsif ($res->cont=
ent
> > eq "AUTHORISED") {
>
> > $subject =3D "APC Result - AUTHORISED";
> > $message =3D "NOCHEX RESPONSE:
> > AUTHORISED\n-----------------------------------------------\nOrder
> > submitted
> > with ID:
> > ".$order_id."\n-----------------------------------------------\ntransac=
tion
> > id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfro=
m
> > email:\t".$from_email."\nto
> > email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\n=
secu
> > rity
> > key:\t".$security_key."\n";} elsif ($res->content eq "DECLINED") {
>
> > $subject =3D "APC Result - DECLINED";
> > $message =3D "NOCHEX RESPONSE:
> > DECLINED\n-----------------------------------------------\nOrder submit=
ted
> > with ID:
> > ".$order_id."\n-----------------------------------------------\ntransac=
tion
> > id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfro=
m
> > email:\t".$from_email."\nto
> > email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\n=
secu
> > rity
> > key:\t".$security_key."\n";} else {
>
> > $subject =3D "Invalid APC Result Returned";
> > $message =3D "The NOCHEX APC server returned an unrecognised or invalid
> > response. In \nall probability due to en error in your code but could b=
e
> > the
> > APC \nserver screwing
> > up.\n-----------------------------------------------\nOrder submitted w=
ith
> > ID:
> > ".$order_id."\n-----------------------------------------------\ntransac=
tion
> > id:\t".$transaction_id."\ntransaction date:\t".$transaction_date."\nfro=
m
> > email:\t".$from_email."\nto
> > email:\t".$to_email."\norder_id:\t".$order_id."\namount:\t".$amount."\n=
secu
> > rity
> > key:\t".$security_key."\n";
>
> > }
>
> > print "Content-Type: text/plain\n\n";
>
> > if ($mail_method eq "smtp") {
> > use Net::SMTP;
> > $smtp =3D 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
We don't like socialists in our newsgroup. We'll be seeing not again
commie.
PERMO
------------------------------
Date: Thu, 07 Jan 2010 16:37:15 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: LWP::UserAgent HTTP POST authentication problem
Message-Id: <%6v1n.3037$Kq7.1993@newsfe04.iad>
Permostat wrote:
> We don't like socialists in our newsgroup. We'll be seeing not again
> commie.
>
> PERMO
If you're going to post nonsense, you could at least snip the text. We
all know you're know Shendley, so your efforts are in vain (it'll just
win more support for the person you're attempting to harass).
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 7 Jan 2010 23:59:36 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: perl in BartPE: locale warning
Message-Id: <slrnhkctb7.bhv.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-01-06, Keith R. Watson <keith.watson@cc.gatech.edu> wrote:
>> Why? Cannot BartPE "just load the .reg" file at runtime?
> You could try the following:
...
> 3. Boot the machine with the BartPE CD.
> 4. Import the .reg files
This is exactly the procedure I was asking about. So why did your
plugin goes in circles (via the main HIV of BartPE) instead of going
this itself (only, of course, automated)?
This might add half-a-second to boot time, but would make
customization so much easier...
> settings. However, I don't know if the locale settings take effect
> immediately or not. Some registry keys work as soon as you change them in
> the registry and others require telling the operating system to reload
> their settings from the registry. You could try it and see if it works.
AHA! This might answer my question... Unfortunately, right now I do
not have a Windows machine at hand to export the .reg file (I would
use US)...
On the other hand, switching users may switch the locale at runtime,
right? So it looks like this setting MUST have immediate effect.
>> And, btw, would not BartPE-builder be able to emit .reg for a certain
>> subtree automatically?
> When you the BartPE utility runs it gets the Windows files from a Windows
> install CD and not from the machine the utility is running on. There are
> not registry keys on the Windows install CD for it to export.
My question was, in fact, more about "tools" than about the actually
used procedure. Are there command-line tools to emit the .reg file
for the given subtree of a running system?
I see that you explicitly mention Perl in your plugin. It may be
simpler with Perl, right?
Thanks again,
Ilya
P.S. I have not googled for it yet, but maybe people here know right
away about installing keyboard layouts with BartPE?
------------------------------
Date: Fri, 8 Jan 2010 01:30:18 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl in BartPE: locale warning
Message-Id: <aeei17-5ne2.ln1@osiris.mauzo.dyndns.org>
Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
>
> My question was, in fact, more about "tools" than about the actually
> used procedure. Are there command-line tools to emit the .reg file
> for the given subtree of a running system?
You can use regedit from the command line to do this. I can't remember
the sytax but if it's not in the help (and IIRC it isn't as of WinXP)
I'm sure Google can find it.
> I see that you explicitly mention Perl in your plugin. It may be
> simpler with Perl, right?
Presumably once you know what the BartPE .inf format is it would be
straightforward to write a Perl program to write such files straight
from the running registry with Win32::TieRegistry.
Ben
------------------------------
Date: Thu, 07 Jan 2010 14:14:33 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Regex to extract email from .msg
Message-Id: <hi5br8$vbc$1@news.eternal-september.org>
Bart Van der Donck wrote:
> 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
>
Are you sure they are spaces and not NULs? Windows text files
frequently use 16-bit wide character format, which looks like
0x0 in the high byte and ASCII in the low byte for English
characters.
http://www.microsoft.com/opentype/unicode/cs.htm
------------------------------
Date: Thu, 07 Jan 2010 16:34:47 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: Regex to extract email from .msg
Message-Id: <I4v1n.3036$Kq7.2874@newsfe04.iad>
Bart Van der Donck wrote:
> 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) { ...
Maybe try stripping hidden characters from the file first? Trying to
guess just exactly how many spaces or other characters, can be a
hassle. The problem is, another address could be completely
inconsistent from another, I assume they aren't all the same? If so,
and if they are really white space, maybe \s+ in place of \s\s\s would
be better? Also, why are you capturing \s\s\s, is that intentional? Is
that expected and what you want? Anyway, you probably need to convert
the file/data to strip out the junk so you can get the actual data you
want and not try and work around ignoring or grabbing that junk
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 07 Jan 2010 16:35:40 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Regex to extract email from .msg
Message-Id: <39vck5lpfr0e68nkelp7d7ostk2cdnkmtl@4ax.com>
Bart Van der Donck <bart@nijlen.com> wrote:
>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.
This file is likely in UTF-16 or USC-2. Did you look at it in a
hex/binary editor? Those spaces are probably 0x00 bytes and not really
spaces at all.
Use the proper encoding and Perl should be able to read the file just
fine,
jue
------------------------------
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 2758
***************************************