[32013] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3277 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 6 00:09:30 2011

Date: Sat, 5 Feb 2011 21:09:12 -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           Sat, 5 Feb 2011     Volume: 11 Number: 3277

Today's topics:
    Re: access anonymous variable sln@netherlands.com
    Re: access anonymous variable <jl_post@hotmail.com>
    Re: access anonymous variable sln@netherlands.com
    Re: access anonymous variable (Seymour J.)
        Fully functional email client <iaoua.iaoua@gmail.com>
    Re: Sys::Syslog question <whynot@pozharski.name>
    Re: upload module to CPAN (http client) <brian.d.foy@gmail.com>
    Re: upload module to CPAN (http client) <rvtol+usenet@xs4all.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 04 Feb 2011 15:17:07 -0800
From: sln@netherlands.com
Subject: Re: access anonymous variable
Message-Id: <nr1pk61t77dd55gbns1hpp9mdcplsg8dfm@4ax.com>

On Fri, 4 Feb 2011 11:04:01 -0800 (PST), "jl_post@hotmail.com" <jl_post@hotmail.com> wrote:

>
>
>
>
>On Feb 1, 5:20 am, "George Mpouras"
><nospam.gravital...@hotmail.com.nospam> wrote:
>> At the following example I want to alter the value of $counter variable ,
>> but without using the the $iter code reference.
>> I 've tried many tricks using __ANON__ but without luck . Can you help ?
>>
>> my $iter = Create_counter(  37);
>>
>> for (1..3)
>> {
>>    print "$_) ". $iter->() ."\n"
>> }
>>
>> sub Create_counter
>> {
>>    my $counter = $_[0];
>>
>>    return sub
>>    {
>>       $counter++
>>    }
>> }
>
>
>Dear George,
>
>   The problem with trying to alter the $counter variable is that it
>is a variable that only gets modified inside the Create_counter()
>subroutine and the function it returns.
>
>   Basically, you're using a closure.  Read up on "perldoc -q closure"
>for a better idea of what a closure is.
>
>   When you assign the subroutine reference to $iter with the line:
>
>      my $iter = Create_counter(37);
>
>you're giving $iter the only power to modify the $counter variable
>that was created in the call to Create_counter() .  From here on, the
>only way to modify that specific instance of $counter is to call $iter-
>>() .

What about:

 return sub {
          if ($_[0]) {
             $counter = $_[0];
          } else {
             $counter++
       }

then $iter->(0) and  $iter->(),
or is that too much out of range of the intended use of an itterator?

-sln


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

Date: Fri, 4 Feb 2011 16:17:15 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: access anonymous variable
Message-Id: <95f409ee-06b4-4a51-a1ff-fea9896e38b6@k7g2000yqj.googlegroups.com>

On Feb 4, 4:17=A0pm, s...@netherlands.com wrote:
>
> What about:
>
> =A0return sub {
> =A0 =A0 =A0 =A0 =A0 if ($_[0]) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0$counter =3D $_[0];
> =A0 =A0 =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0$counter++
> =A0 =A0 =A0 =A0}
>
> then $iter->(0) and =A0$iter->(),
> or is that too much out of range of the intended use of an itterator?


   That would work for setting $counter -- but only to a non-zero
value.  (The way it is now, $iter->(0) will increment $counter.)

   As for peeking at the value of $counter (that is, reading it
without modifying it), you might have to do this:

      print $iter->( $iter->() );

but that might still increment the $counter, depending on when exactly
the '++' operator decides to fire off.  (I'm not sure if that's well
defined in this case or not.)

   Cheers,

   -- Jean-Luc


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

Date: Fri, 04 Feb 2011 17:07:20 -0800
From: sln@netherlands.com
Subject: Re: access anonymous variable
Message-Id: <ma8pk65sqgjjf749v0jlo5vr79qgg1h8t4@4ax.com>

On Fri, 4 Feb 2011 16:17:15 -0800 (PST), "jl_post@hotmail.com" <jl_post@hotmail.com> wrote:

>On Feb 4, 4:17 pm, s...@netherlands.com wrote:
>>
>> What about:
>>
>>  return sub {
>>           if ($_[0]) {
>>              $counter = $_[0];
>>           } else {
>>              $counter++
>>        }
>>
>> then $iter->(0) and  $iter->(),
>> or is that too much out of range of the intended use of an itterator?
>
>
>   That would work for setting $counter -- but only to a non-zero
>value.  (The way it is now, $iter->(0) will increment $counter.)
>
>   As for peeking at the value of $counter (that is, reading it
>without modifying it), you might have to do this:
>
>      print $iter->( $iter->() );
>
>but that might still increment the $counter, depending on when exactly
>the '++' operator decides to fire off.  (I'm not sure if that's well
>defined in this case or not.)
>

'if ($_[0])'  I didn't see that foible.

I guess poke and peak could be done
  return sub {
           if (defined $_[0]) {
              $counter = $_[0];
           } else {
              $counter++
        }
print $iter->( $iter->() - 1 );  # but this isin't understandable

or  ---
  return sub {
           if (defined $_[0]) {
              $counter = ($_[0] =~ /[a-zA-Z]/) ? $counter : $_[0]; 
           } else {
              $counter++
        }
print $iter->( 'getval' );
print $iter->(0);

As long as the itterator does its main function correctly,
anything could be done in the sub, right?

-sln


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

Date: Sat, 05 Feb 2011 20:21:31 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: access anonymous variable
Message-Id: <4d4df79b$3$fuzhry+tra$mr2ice@news.patriot.net>

In <ii8tqn$2igj$1@ulysses.noc.ntua.gr>, on 02/01/2011
   at 02:20 PM, "George Mpouras"
<nospam.gravitalsun@hotmail.com.nospam> said:

>At the following example I want to alter the value of $counter
>variable , 

If you have multiple calls to Create_counter, do you require multiple
counter variables or a single counter variable? 

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Sat, 5 Feb 2011 18:23:56 -0800 (PST)
From: iaoua iaoua <iaoua.iaoua@gmail.com>
Subject: Fully functional email client
Message-Id: <65407d4c-52b2-489e-aedd-6679a0bd817c@glegroupsg2000goo.googlegroups.com>

Hi all,

Newbie alert. I'm new to this newsgroup so please be nice to me. I'm not co=
mpletely new to Perl but not exactly a Guru and not exactly much more than =
a complete novice so please bear with me.

My name is James Christian and I am PhD research student at the University =
of Essex in the UK. You can see a picture of me with my little daughter on =
my very basic webpage privatewww.essex.ac.uk/~jcread

Anyway, apart from machine tranlation research in my spare time I have deve=
loped a conversational agent that dialogues with users to find out what the=
y are really looking for (gone are the days of simple keyword search). I ha=
ve a growing base of experimental users for my alpha release who currently =
need to come into my office to use the system as it is not web borne. The s=
ystem can take some time to answer questions because of the comlexity of th=
e task (the system is still learning). It asks the user questions to figure=
 out what they want and then sends them off to the right website or busines=
s that has the products, services, information or free downloads that they =
require

e.g.

Hi, how can I help you?
Where can I download music?
Erm, lots of different places what were you looking for exactly?
A song by U2?
Which song exactly?
 ...

This goes on until the system has completely matched the user's requirement=
s. It can take some time for the inference engine to figure out a satisfyin=
g answer and if the answer turns out not to be satisfying then the system h=
as to go into dialogue to make new suggestions and learn from user feedback=
 . As the system is slow at decision making my growing user base has asked i=
f they can play with the system by email instead of having to sit in my off=
ice and wait for a long time for the system to generate responses.

So what I basically need is a solution I can drop my conversational agent i=
nto. Some kind of fully functional email client that already absracts away =
the details of receiving and sending messages. Generating message ids for t=
hreading. Extracting the new text which is the response to the last email e=
tc. I need something I can just drop my agent into with minimal parameter s=
etting such as configuring the SMTP and POP servers to be used, user name a=
nd password and port numbers etc. Something my system can just automaticall=
y hit the reply button to and respond to a question. Something my can easil=
y extract the relevant text from without having to worry about implementati=
on details of designing a full email client from first principals.

Basically, I need a command line version of Thunderbird but that already ex=
tracts the new line of text as input to my agent. Surely, there must be som=
ething like that out there already done in Perl. Can anyone point me to any=
thing? Or is it noses to the grindstone time?

Thanks for any advice you can give me guys.

James Christian
http://www.iaoua.com


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

Date: Sat, 05 Feb 2011 12:42:31 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Sys::Syslog question
Message-Id: <slrnikqacm.hhi.whynot@orphan.zombinet>

with <fV45K0OBJxbE-pn2-djbSFegGnbeu@localhost> Dave Saville wrote:
> On Fri, 4 Feb 2011 12:36:06 UTC, Martijn Lievaart <m@rtij.nl.invlalid>
> wrote:
>
>> On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:
*SKIP*
>> > The question is, which is best practice?
>> > 
>> > 1) Inside the read pipe loop - openlog, write, close log for every
>> > line.
>> > 2) Openlog outside the pipe read loop and write each line as it
>> > comes?  ie keep the file open.
>> 
>> What's wrong with option 2?
>> 
>
> Well I am not sure if keeping an open connection to the syslogd daemon
> for days on end is a good idea :-)

Sysloging over network is of UDP kind, thus no-connection.  OTOH, if
there's any connection with /dev/log I can't say without investigation
(and, honestly, I'm not interested).  And please note,  fork(2) is
costly.  open(2) isn't.  You can safely (if you wish) open-write-close.
With amounts of bytes you're going to syslog you'll see no problems.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

Date: Sat, 05 Feb 2011 10:09:30 -0600
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: upload module to CPAN (http client)
Message-Id: <050220111009306877%brian.d.foy@gmail.com>

In article
<5964fa37-8869-43cd-a69e-37d1506d3e19@r19g2000prm.googlegroups.com>,
Loofort <loofort@gmail.com> wrote:

> I think to prefix packages with "CTX" - meaning "context" since http
> (and specially ftp) works in context - pass the cookies, understand
> relative links, keep alive connections etc.

PAUSE has some naming advice. There's not much context for CTX, so you
might choose another top-level namespace :)

https://pause.perl.org/pause/query?ACTION=pause_namingmodules


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

Date: Sat, 05 Feb 2011 23:48:49 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: upload module to CPAN (http client)
Message-Id: <4d4dd3d1$0$32470$e4fe514c@news.xs4all.nl>

On 2011-02-05 17:09, brian d foy wrote:
> In article
> <5964fa37-8869-43cd-a69e-37d1506d3e19@r19g2000prm.googlegroups.com>,
> Loofort<loofort@gmail.com>  wrote:

>> I think to prefix packages with "CTX" - meaning "context" since http
>> (and specially ftp) works in context - pass the cookies, understand
>> relative links, keep alive connections etc.
>
> PAUSE has some naming advice. There's not much context for CTX, so you
> might choose another top-level namespace :)
>
> https://pause.perl.org/pause/query?ACTION=pause_namingmodules

"pause.perl.org uses an invalid security certificate."

-- 
Ruud


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

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


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