[22829] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5050 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 28 00:05:36 2003

Date: Tue, 27 May 2003 21:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 May 2003     Volume: 10 Number: 5050

Today's topics:
    Re: a Bayesian intelligent e-mail autoresponder? (Western Larch)
        BUG: Can't locate object method "SWASHNEW" via package  <recycle@bin.com>
    Re: converting binary string to numbers <bwalton@rochester.rr.com>
    Re: converting string of [01] to (binary) number <wksmith@optonline.net>
    Re: DBI query to Informix takes 20sec to end (Bob Mariotti)
        distributing extensions to Perl <ericw@nospam.ku.edu>
    Re: distributing extensions to Perl (Malcolm Dew-Jones)
    Re: distributing extensions to Perl <ericw@nospam.ku.edu>
    Re: Doing substitutions in a while loop (while /.../g) <uri@stemsystems.com>
    Re: Doing substitutions in a while loop (while /.../g) (Tad McClellan)
    Re: LWP::Useragent needs to be flushed if the response  <bwalton@rochester.rr.com>
        Making Perl scripts executable on Win32 (John)
    Re: Making Perl scripts executable on Win32 <kevin@vaildc.net>
    Re: Making Perl scripts executable on Win32 (Malcolm Dew-Jones)
    Re: Regexp Multiple Matching Problem <eric-amick@comcast.net>
    Re: scope of variable <mgjv@tradingpost.com.au>
    Re: scope of variable <recycle@bin.com>
    Re: What is expilcit package name? <bbsouth@bellsouth.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 May 2003 19:49:11 -0700
From: larix_occidentalis@yahoo.com (Western Larch)
Subject: Re: a Bayesian intelligent e-mail autoresponder?
Message-Id: <6869c57c.0305271849.6c3b8ab2@posting.google.com>

Yeff <yeff@myrealbox.com> wrote:

> On 26 May 2003 07:03:56 -0700, totojepast wrote:
> 
> > Please can you tell me if anybody has tried to use ifile or a similar
> > Bayesian for an automatic e-mail autoresponder?
> 
> If I grok what you're trying to do (automatically identify and bounce 
> spam?) then all I can say is that the concept is *evil*.
> 
> "Evil, pure and simple from the eighth dimension!"
> 
> You're doubling the amount of traffic generated by the spam and probably 
> bouncing your messages to bogus addresses (not the people who actually sent 
> the spam).

Relax, dude. Why not take the proposal as a springboard for 
further development? No need to get bent out of shape.

How about this: instead of replying to every apparent spam message,
reply only to the ones which look like they might possibly be non-spam.
So if every message is assigned a score, and the scores above a 
threshold are thrown out as spam, then messages near but just above
the threshold would merit a reply.

I'm thinking 1% or fewer. Presumably the right way to figure out the
two thresholds (one for spam, and a slightly higher one for spam-which-
gets-a-reply) is to assign costs to reading spam, throwing away non-spam,
bothering to reply to spam, and replying to a nonspam. 

I'm pretty sure that spam filters have deleted > 1 nonspam message
addressed to me. I'm pretty sure that I'd like to get those messages
resent.

L.


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

Date: Wed, 28 May 2003 04:57:28 +0200
From: "Craig Manley" <recycle@bin.com>
Subject: BUG: Can't locate object method "SWASHNEW" via package "utf8" (perhaps you forgot to load "utf8"?)
Message-Id: <3ed4259c$0$137$e4fe514c@dreader7.news.xs4all.nl>

Hi,

I'm using Perl 5.6.1 on RedHat Linux when this bug occurs.
It occurs on the last line of this snippet when "uc" is called:

   my @cmd_args;
   if (length($msg) > length($keyword)) {
    @cmd_args = split(/\s+/,substr($msg,length($keyword)));
   }
   # Handle command based on arguments
   if (@cmd_args) {
    $cmd_args[0] = uc($cmd_args[0]);
   }


The value in $msg comes from an XML::RPC call from another script
(encoding/sending done by XMLRPC::Lite)
that has been parsed by Frontier::Client (in this script).

Strange thing is that this error does not occur on another Linux machine
using Perl 5.6.1 and another strange thing is that the error does not occur
when other functions on $msg are called such as length(), split(), s///,
substr(), etc.

Does anybody understand what's causing this error?

-Craig Manley




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

Date: Wed, 28 May 2003 01:45:34 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: converting binary string to numbers
Message-Id: <3ED413A4.5080509@rochester.rr.com>

Eric Moors wrote:

> I'm trying to split a string of n*8 characters
> in their hexadecimal counterparts. A small example:

 ...

Please don't post the same thing twice.

-- 
Bob Walton



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

Date: Wed, 28 May 2003 02:22:41 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: converting string of [01] to (binary) number
Message-Id: <R3VAa.6641$Ah3.2949079@news4.srv.hcvlny.cv.net>


"Eric Moors" <scare.crow@oz.land> wrote in message
news:pan.2003.05.27.13.39.31.604104.14972@oz.land...
> I'm trying to split a string of n*8 characters
> in their hexadecimal counterparts. A small example:
>
> As input I have the ascii string:
>
> "0000_0000_0011_0000_1010_1100"
>
> and I want to convert this to the ascii string:
>
> 00
> 30
> AC
>
> So I first split the string in n byte parts,
> But how can I convert each part to a number?
> The code below works, but I cannot help thinking there
> must be an easier way. (It's more C'ish than perl'ish)
> I looked into (un)pack, but couldn't get any lifesign
> out of that.

pack and unpack sounded right to me.  It can be done, but it was much
harder than I expected.  My pack returns an array of hex digits.  My
method of arranging them into pairs for printing is awkward.

use strict;
use warnings;
my $b_str = "0000_0000_0011_0000_1010_1100";
my $pk = pack "B4B4B4B4B4B4", split("_", $b_str);
my @hex = unpack ("HHHHHH", $pk);
my @hex2 = map (join ("", $hex[2*$_],$hex[2*$_+1]), (0..2));
print join("\n", @hex2);

I am not sure if this is useful, but had fun doing it.
Bill




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

Date: Wed, 28 May 2003 02:29:55 GMT
From: R.Mariotti@FinancialDataCorp.com (Bob Mariotti)
Subject: Re: DBI query to Informix takes 20sec to end
Message-Id: <3ed41ed7.7342460@news.cshore.com>

On 27 May 2003 15:28:40 -0700, cfa532@hotmail.com (Thomas) wrote:

>I used Perl DBI to access Informix IDS 2000 on Solaris 2.8. The query
>is a simple SELECT and it gets data from Informix pretty quick.
>However it takes up to 20s for the prompt to show up after all data is
>displayed, sometime it is quick though. I don't see anything else
>wrong other than the long wait. My database is logged.
>
>Thanks a lot,

If you're selecting on an indexed field

then carefully check your syntax of the select statement and the
field(s) you are selecting on.  If they're NOT quoted properly I've
found that perl will change the field type which can cause a
sequential search of the ENTIRE DB.

Bob


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

Date: Wed, 28 May 2003 02:57:53 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: distributing extensions to Perl
Message-Id: <pan.2003.05.27.21.54.44.174563.32388@nospam.ku.edu>

From my understanding of the GPL and the process of extending Perl with
dynamically-linked C code, any distribution of such code seems to require
a GPL-compatible license.

The module in question links against a non-GPL (closed-source, but freely
available) toolkit, providing a Perl interface to the methods contained
in the toolkit.

Anyone have any experience in such matters?

I'm looking for clarification on how which part of which code is affected
by which license.  There are no plans for binary distribution, or even
distribution of the non-GPL library, but simply for open-sourcing the
SWIG interface file and helper functions.

Thanks in advance,
Eric Wilhelm


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

Date: 27 May 2003 20:19:49 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: distributing extensions to Perl
Message-Id: <3ed42ad5@news.victoria.tc.ca>

Eric Wilhelm (ericw@nospam.ku.edu) wrote:
: From my understanding of the GPL and the process of extending Perl with
: dynamically-linked C code, any distribution of such code seems to require
: a GPL-compatible license.

Perl is not a GPL program.  It has that option, but also other licensing
options.  (At least last time I read the licensing details.) 



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

Date: Wed, 28 May 2003 03:42:13 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: distributing extensions to Perl
Message-Id: <pan.2003.05.27.22.39.07.16164.32388@nospam.ku.edu>

On Tue, 27 May 2003 23:19:49 -0500, Malcolm Dew-Jones wrote:

> Eric Wilhelm (ericw@nospam.ku.edu) wrote: : From my understanding of the
> GPL and the process of extending Perl with : dynamically-linked C code,
> any distribution of such code seems to require : a GPL-compatible
> license.
> 
> Perl is not a GPL program.  It has that option, but also other licensing
> options.  (At least last time I read the licensing details.)

Ah, yes.  Thank you for pointing that out.  I have just now read the
artistic license shipped with the source-code package.  This seems to say
that any libraries linked to the Package are construed as input, so that
this would fall under the terms of "Aggregation".

I think I may also use this Artistic license for the distribution of my
module.

--Eric


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

Date: Wed, 28 May 2003 01:30:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Doing substitutions in a while loop (while /.../g)
Message-Id: <x7fzmzluxh.fsf@mail.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:

  TM> What? You don't re-read perlop.pod every once in a while?

  TM> I do. I find out something I didn't catch the first time each
  TM> time I re-read it.

s/first/previous/

and i always recommend re-reading the perl docs. just for all of you out
there, how do you think the gurus get to know so much perl? they read
the docs and repeat. i don't know of a single decent perl hacker who
would claim otherwise. it is the best way to learn more perl. you find
new feature and options and such and then figure out why they were
created and how can you use them. you can read crossreferenced docs as
well and that opens up new perl territories. read the tutorials for a
given subject and you might find an example that you can steal.

this goes back to the early days of unix when you were expected to
browse man pages on a regular basis. they were written in a style that
needs regular re-reading and cross reference reading. you didn't ever
just read the single man page but followed the 'see also' links.

you shouldn't just read perldoc perlop to learn about /e on s/// but
then follow it with perldoc perlre and maybe perlrequick and
perlretut. then you go read MRE. then you do it again when you need to
learn more about regexes and s///.

so any time you see a regular pointing a poster to the docs, this is
why. when we get flames from those who don't like it, this is why we
ignore them. the perl docs are the way to learn perl. all else is
commentary and explanatory and tutorial.

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


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

Date: Tue, 27 May 2003 22:11:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Doing substitutions in a while loop (while /.../g)
Message-Id: <slrnbd8a6j.3jc.tadmc@magna.augustmail.com>

Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in 
> news:slrnbd7ua0.3br.tadmc@magna.augustmail.com:
> 
>> What? You don't re-read perlop.pod every once in a while?
>> 
>> I do. I find out something I didn't catch the first time each
>> time I re-read it.
> 
> Geek.  ;-)


I have to have _something_ to read when I'm in the 
smallest room in my house...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 28 May 2003 01:33:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: LWP::Useragent needs to be flushed if the response is huge
Message-Id: <3ED410E2.5070805@rochester.rr.com>

Nagaraj wrote:

> We are using the LWP UserAgent class.  It works great except when very 
> large content is returned.  When that happens none of the output gets 
> flushed until the entire page is cached.  According to the documentation 
> their is a way to use the object and pass it a subroutine to handle the 
> output (possibly in small chunks :) 
> My question is:  Does anyone have a code fragment that would help us 
> implement a subroutine that would simple flush the content as it arrives?
> Thanks in Advance.
> 

See

    perldoc lwpcook

and look under the "Large Documents" section.

-- 
Bob Walton



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

Date: 27 May 2003 18:12:47 -0700
From: experiment62002@yahoo.com (John)
Subject: Making Perl scripts executable on Win32
Message-Id: <803d536c.0305271712.26b69bfc@posting.google.com>

I've just installed Perl 5.8 on a machine running Windows XP Home, and
right now I have to explicitly call Perl (e.g. C:\> perl script.pl) to
execute a script.  Just typing the name of the script opens the file
in Notepad, which I assume is the default action.  I was hoping to
find out how to make my Perl scripts exectable, preferably
system-wide, or at the very least if there is something akin to "chmod
755" that I can use on individual files.  Thanks.


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

Date: Tue, 27 May 2003 22:53:36 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Making Perl scripts executable on Win32
Message-Id: <kevin-82B3C4.22533627052003@vienna7.his.com>

In article <803d536c.0305271712.26b69bfc@posting.google.com>,
 experiment62002@yahoo.com (John) wrote:

> I've just installed Perl 5.8 on a machine running Windows XP Home, and
> right now I have to explicitly call Perl (e.g. C:\> perl script.pl) to
> execute a script.  Just typing the name of the script opens the file
> in Notepad, which I assume is the default action.  I was hoping to
> find out how to make my Perl scripts exectable, preferably
> system-wide, or at the very least if there is something akin to "chmod
> 755" that I can use on individual files.  Thanks.

This can be done.  You have to add .pl to the PATHEXT environment 
variable, and associate .pl files with perl.  I did the first from 
Properties on My Computer -> Advanced -> Environment Variables, and the 
second by modifying the Registry, but there are probably easier ways to 
do either one.  (I'm not a Windows guy, but it's what I have to use at 
work.)
-- 
Kevin Michael Vail | Dogbert: That's circular reasoning.
kevin@vaildc.net   | Dilbert: I prefer to think of it as no loose ends.
http://www.vaildc.net/kevin/


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

Date: 27 May 2003 20:04:42 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Making Perl scripts executable on Win32
Message-Id: <3ed4274a@news.victoria.tc.ca>

John (experiment62002@yahoo.com) wrote:
: I've just installed Perl 5.8 on a machine running Windows XP Home, and
: right now I have to explicitly call Perl (e.g. C:\> perl script.pl) to
: execute a script.  Just typing the name of the script opens the file
: in Notepad, which I assume is the default action.  I was hoping to
: find out how to make my Perl scripts exectable, preferably
: system-wide, or at the very least if there is something akin to "chmod
: 755" that I can use on individual files.  Thanks.

The easiest is to convert them to batch files.  type 

	pl2bat -h

for some instructions.

Also read about "perl -x", which is the key thing that the conversion
above does to create a combined dos-batch/perl-script file.  You can use
perl -x multiple times in a batch file, and use perl kind of like a
subroutine within the batch file.

Or make a wrapper batch file for the perl script.  Having two files looks
a bit redundant, but may have the advantage that the perl script might run
as-is on other systems, and might be easier to debug if it's non-trivial. 



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

Date: Tue, 27 May 2003 21:35:15 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Regexp Multiple Matching Problem
Message-Id: <t938dvc67acfto88nrgoh53p3p1qq32hsc@4ax.com>

On 23 May 2003 06:29:52 -0700, jonasb@alum.rpi.edu (Big Brother) wrote:

>Thanks for your replies. I figured I'd be a little more specific with
>the code. I'm pretty sure that the problem lies in the variable that I
>use to get the matched string, but I've looked through the docs and am
>not sure what to use.
>
>        if ($_=~m/$RE{net}{IPv4}{dec}{-keep}/g)   #Find IP Address

-keep looks like an expression to Perl, so it won't be quoted the way
the other subscripts are. Unless you have a function called keep, I
suspect you really want '-keep' with the quotes.  If my assumption is
correct, you can also change the /g to /go since the subscript values
(and hence the hash element selected) won't change.  That will keep the
regex from being recompiled each time.

>        {
>                if ($objects{$1}==NULL)         #Already in hash?

This test creates the hash element if it doesn't already exist; is that
what you want?  Where and how is NULL defined?

>                {
>                        $objects{$1}=(16777215-$i); #hash to determine
>color
>                        $i+=65433;
>                }
>                $hlight=$1;
>                $color=sprintf("%04x",$objects{$1});
>
>                s/$hlight/<A
>HREF=\"http:\/\/$serverip\/cgi-bin\/s2h.cgi?t=$t&nm=$nm&filter=$hlight\"><SPAN
>style=\"background-color: #$color\">$hlight<\/SPAN><\/A>/g;

If you change the delimiters, you can spare yourself at least some of
the backslashes:

s|$hlight|<A
HREF=\"http://$serverip/cgi-bin/s2h.cgi?t=$t&nm=$nm&filter=$hlight\"><SPAN
style=\"background-color: #$color\">$hlight</SPAN></A>|g;

-- 
Eric Amick
Columbia, MD


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

Date: Wed, 28 May 2003 01:48:03 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: scope of variable
Message-Id: <slrnbd85aj.1lr.mgjv@verbruggen.comdyn.com.au>

On 27 May 2003 02:16:58 -0700,
	fatted <fatted@yahoo.com> wrote:
> Consider code:
> 
> use warnings;
> use strict;
> 
> open(OUT,'>>','program.log');
> 
> while(1)
> {
>         sleep(3);
>         print OUT "Hello\n";
> }
> 
> With the strict pragma, the filehandle OUT is not available in the
> while block, but opening a filehandle in the while loop, will result
> in a call to open every 3 seconds. Any idea's? I thought I might be
> able to globally define the file handle using:

Is the warning message you get something like:

print() on unopened filehandle OUT at ......

If so, check that your open succeeded. I'm pretty sure that it didn't.

> our *OUT; 
> 
> before the open call, but the compiler didn't like that :)

No need. Even if that worked syntactically, and the filehandle OUT was
in some way lexically scoped, then that scope would already cover the
inside of the loop. In this case, OUT is global anyway.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | Curiouser and curiouser, said Alice.
                        | 


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

Date: Wed, 28 May 2003 05:27:07 +0200
From: "Craig Manley" <recycle@bin.com>
Subject: Re: scope of variable
Message-Id: <3ed42c95$0$131$e4fe514c@dreader4.news.xs4all.nl>

"fatted" <fatted@yahoo.com> wrote in message
news:4eb7646d.0305270116.665b04ab@posting.google.com...
> Consider code:
>
> use warnings;
> use strict;
>
> open(OUT,'>>','program.log');
>
> while(1)
> {
>         sleep(3);
>         print OUT "Hello\n";
> }
>
> With the strict pragma, the filehandle OUT is not available in the
> while block, but opening a filehandle in the while loop, will result
> in a call to open every 3 seconds. Any idea's? I thought I might be
> able to globally define the file handle using:
>
> our *OUT;
>
> before the open call, but the compiler didn't like that :)

Hi, maybe I'm wrong because nobody else seems to suggest this, but why use
globals when you can keep the scope down to "my" variables:

use warnings;
use strict;

# do some file work
if (1) {
 my $h;
 open($h,'>>','program.log');
 while(&may_continue()) {
        sleep(3);
        print $h "Hello\n";
 }
 close($h);
}




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

Date: Tue, 27 May 2003 20:35:10 -0500
From: "Brett" <bbsouth@bellsouth.net>
Subject: Re: What is expilcit package name?
Message-Id: <CcUAa.30853$r11.8441@fe10.atl2.webusenet.com>


"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3ed404f5.163656684@news.erols.com...
> "Brett" <bbsouth@bellsouth.net> wrote:
>
> : I'm getting this error:
> :
> : syntax error at C:\Inetpub\mb\ubbcgi\ultimatebb.cgi line 545, near "my "
> : Global symbol "$cookie2" requires explicit package name at
> : C:\Inetpub\mb\ubbcgi\ultimatebb.cgi line 545. Execution of
> : C:\Inetpub\mb\ubbcgi\ultimatebb.cgi aborted due to compilation errors.
> :
> : What does it mean?
>
> The "global symbol" bit is a red herring.  Fix the syntax error, and
> the others will most likely go away.
>
> Betcha line 544 lost its trailing semicolon.
>

You were very close and helped me solve the problem.  I've included two line
numbers below.  Line 544 had a "!" instead of a comment "#".  Here's the
incorrect code:

538  my $cookie1 = cookie(
   -name  => "session$vars_config{Cookie_Number}",
   -value => [$last_login_dt, $last_login_j],
   -path  => '/'
  );

544  ! set new last login
  my $cookie2 = cookie(
   -name    => "login$vars_config{Cookie_Number}",
   -value   => [$GotTime{LastLoginDT}, $GotTime{LastLoginJulian}],
   -path    => '/',
   -expires => '+1y'
  );

Correct code:
544  # set new last login
  my $cookie2 = cookie(
   -name    => "login$vars_config{Cookie_Number}",
   -value   => [$GotTime{LastLoginDT}, $GotTime{LastLoginJulian}],
   -path    => '/',
   -expires => '+1y'
  );


Thanks very much all,
Brett





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

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 5050
***************************************


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