[32490] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3755 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 00:09:19 2012

Date: Thu, 9 Aug 2012 21:09:04 -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           Thu, 9 Aug 2012     Volume: 11 Number: 3755

Today's topics:
        Netnews for Gen X <oneingray@gmail.com>
    Re: Time Question <edgrsprj@ix.netcom.com>
    Re: Using variable in replacement expression (Tim McDaniel)
    Re: Using variable in replacement expression rob@sypron.nl
    Re: Using variable in replacement expression rob@sypron.nl
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Aug 2012 19:47:34 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Netnews for Gen X
Message-Id: <86a9y4i655.fsf_-_@gray.siamics.net>

>>>>> Shmuel (Seymour J ) Metz <spamtrap@library.lspace.org.invalid> writes:
>>>>> In <86sjbxii9v.fsf@gray.siamics.net>, Ivan Shmakov said:

	[Dropping news:comp.lang.perl.misc from Followup-To: as a matter
	of habit.]

 >> After the data is downloaded from a P2P network (it may be
 >> BitTorrent, GNUnet, Freenet, or whatever else), it could be used
 >> off-line just perfectly.

 > Do those have the routing capabilities that mail and news require?

	The current Netnews architecture relies, in essence, on a
	simplistic flood-fill routing.  That is, for each group, we can
	imagine a network of nodes, each of which, upon receipt of a new
	message, relays it to all of its peers.  The only two things
	that complicate this scheme are Path: and IHAVE, which both
	reduce the load by not sending the message the peer already has.

	In this scheme, and taking INN as an example, newsfeeds(5), and
	its reciprocal incoming.conf(5), serve two purposes: they remedy
	the fact that Netnews currently lack autodiscovery (contrary to
	the P2P networks mentioned above), and they code (in a crude,
	but working, fashion) the "trust" relationship between the
	peers.

	However, dealing with "trust" at the link level (and not at the
	user level) can by itself led to certain security implications.

	With a sound use of digital signatures (and implementing the
	relevant WoT, or re-using the OpenPGP one), we can lay the
	control over what's trustworthy and what's not straight to the
	hands of the user.

	The mail routing is a trickier one.  However, considering that
	virtually the only reason behind such a routing nowadays is the
	belief in the security of firewalled intranets, we may simplify
	the whole task of routing to a three-hop (user, relay, user)
	scheme, detailed below.

	Let's first assume that "autodiscovery" is in place.  Now, Alice
	chooses a "relay" (there may be both free of charge and paid
	ones), and her agent puts (into the distributed hash table, or
	DHT) a (digitally-signed) "pointer" record that all her mail
	should be delivered to that relay.  When Bob wants to send mail
	to Alice, its agent searches the DHT, finds the "pointer"
	record, and sends a copy of the letter to the relay thus found.
	(Naturally, Alice's agent checks the relay for any new messages
	periodically when online.)

	It makes sense for the Bob's letter to mention a few of his
	previous messages (sent to Alice) in the header.  This way, it
	would be much harder for a (malicious) relay to hide the
	information of any such message.  Also, it makes sense to
	encrypt all the communication, so such a relay won't be able to
	intercept or tamper the messages, either.

	This scheme could be modified slightly by requesting Bob to copy
	the message he wishes to send to Alice to his own "relay" B,
	while sending only a pointer to Alice's A.  This way, Bob (and
	not Alice) "pays" for the handling of his outgoing letters,
	which may thwart certain abuse scenarios.

	Note that should Mallory try to send numerous pointers to a
	single message, it'd be possible to "mark" such a message as
	"spam" just once per group of users of the "Netnews-like part"
	of the P2P communication system being discussed.

 > Also, wouldn't you still have a separation between a user agent and a
 > transfer agent?

	It /may/ be done, for various reasons, including the
	compatibility with the MUA's currently in use.

	Both GNUnet and Freenet (IIRC) implement an HTTP interface, so
	that an ordinary Web browser can be used to connect to the
	network.  OTOH, BitTorrent agents (commonly called /clients/,
	though it's a misnomer) are mostly self-contained.

 >>> Further, there are security issues.

 >> Namely?

 > E. g., audit trail of the route for mail.

	And what exactly it's for?  I don't see why one may need to care
	/how/ the letter has reached its destination if it's a valid and
	wanted one.  And if it's not, imposing a policy on the relays is
	only a partial solution.

-- 
FSF associate member #7257	http://sf-day.org/


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

Date: Wed, 8 Aug 2012 19:13:24 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Time Question
Message-Id: <1NCdneGhdZY-nb7NnZ2dnUVZ_qWdnZ2d@earthlink.com>

"E.D.G." <edgrsprj@ix.netcom.com> wrote in message 
news:JsednYi0XZ8Oy4TNnZ2dnUVZ_tCdnZ2d@earthlink.com...
> TIME QUESTION

      I have seen all of the postings for this question and the other thread 
regarding the Perl Newsgroup.  And I have done some reading on Date Calc. 
There are several projects that I am trying to finish that have deadlines 
associated with them.  And it will probably be a while before I will have a 
chance to comment on any of the other recent posts.



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

Date: Wed, 8 Aug 2012 22:42:15 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Using variable in replacement expression
Message-Id: <jvuq07$j50$1@reader1.panix.com>

In article <141389db-09e3-43de-89c5-e8cb9ce8abeb@googlegroups.com>,
RobV  <rob@sypron.nl> wrote:
>I'm trying to do a global replace with a varying replacement string
>which includes a counter to count the replacements.
>The idea is this (replacing all "xy" strings):
>   Source: "ab xy cd xy ef xy gh"
>   Result: "ab Mark1 cd Mark2 ef Mark3 gh"
>
>I read through perlre and the best I can come up with is below. Yet
>it doesn't do what I wanted, the replacement is identical every time:
>
>$cnt = 1;
>$replace = '"Mark$cnt"';
>$s = "ab xy cd xy ef xy gh";
>
>while ($s =~ s/xy/$replace/gee) { 
>	  $cnt++;
>}
>print $s;

As a side note: even in a simple test program, it's best to keep the
discipline of
    use warnings;
    use strict;
and "my"ing all variables.

>Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
>
>My understanding of the /ee modifier is that it forces the right-hand
>side to be evaluated every time, but somewhere in my understanding
>something seems to be missing.

Print $cnt after the loop.  You'll see that it's 2.  That means that
the loop iterated only once.

The problem is the "g" modifier.  It replaces ALL occurrences the
first time it runs.

"g" in general is a good idea, to prevent an infinite loop if the RHS
happened to contain the LHS (that is, if $replace contained "xy").

This works for me in 5.14.2:

    my $s = "ab xy cd xy ef xy gh\n";
    my $cnt = 0;
    $s =~ s/xy/++$cnt, "Mark$cnt"/ge;
    print $s;

and therefore

    my $s = "ab xy cd xy ef xy gh\n";
    my $cnt = 0;
    my $replace = '++$cnt, "Mark$cnt"';
    $s =~ s/xy/$replace/gee;
    print $s;

-- 
Tim McDaniel, tmcd@panix.com


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

Date: Wed, 8 Aug 2012 15:49:57 -0700 (PDT)
From: rob@sypron.nl
Subject: Re: Using variable in replacement expression
Message-Id: <66ab8a1e-d4a5-4962-8938-0d3ff5272b29@googlegroups.com>

On Wednesday, August 8, 2012 11:25:27 PM UTC+2, RobV wrote:
> I'm trying to do a global replace with a varying replacement string which includes a counter to count the replacements. 
> 
> The idea is this (replacing all "xy" strings):
> 
>    Source: "ab xy cd xy ef xy gh"
> 
>    Result: "ab Mark1 cd Mark2 ef Mark3 gh"
> 
> 
> 
> I read through perlre and the best I can come up with is below. Yet it doesn't do what I wanted, the replacement is identical every time:
> 
> 
> 
> $cnt = 1;
> 
> $replace = '"Mark$cnt"';
> 
> $s = "ab xy cd xy ef xy gh";
> 
> 
> 
> while ($s =~ s/xy/$replace/gee) { 
> 
> 	  $cnt++;
> 
> }
> 
> print $s;
> 
> 
> 
> Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
> 
> 
> 
> My understanding of the /ee modifier is that it forces the right-hand side to be evaluated every time, but somewhere in my understanding something seems to be missing. 
> 
> 
> 
> I'd be grateful if someone could point me the way.
> 
> Thanks in advance, 
> 
> 
> 
> Rob V.



On Wednesday, August 8, 2012 11:25:27 PM UTC+2, RobV wrote:
> I'm trying to do a global replace with a varying replacement string which includes a counter to count the replacements. 
> 
> The idea is this (replacing all "xy" strings):
> 
>    Source: "ab xy cd xy ef xy gh"
> 
>    Result: "ab Mark1 cd Mark2 ef Mark3 gh"
> 
> 
> 
> I read through perlre and the best I can come up with is below. Yet it doesn't do what I wanted, the replacement is identical every time:
> 
> 
> 
> $cnt = 1;
> 
> $replace = '"Mark$cnt"';
> 
> $s = "ab xy cd xy ef xy gh";
> 
> 
> 
> while ($s =~ s/xy/$replace/gee) { 
> 
> 	  $cnt++;
> 
> }
> 
> print $s;
> 
> 
> 
> Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
> 
> 
> 
> My understanding of the /ee modifier is that it forces the right-hand side to be evaluated every time, but somewhere in my understanding something seems to be missing. 
> 
> 
> 
> I'd be grateful if someone could point me the way.
> 
> Thanks in advance, 
> 
> 
> 
> Rob V.



On Wednesday, August 8, 2012 11:25:27 PM UTC+2, RobV wrote:
> I'm trying to do a global replace with a varying replacement string which includes a counter to count the replacements. 
> 
> The idea is this (replacing all "xy" strings):
> 
>    Source: "ab xy cd xy ef xy gh"
> 
>    Result: "ab Mark1 cd Mark2 ef Mark3 gh"
> 
> 
> 
> I read through perlre and the best I can come up with is below. Yet it doesn't do what I wanted, the replacement is identical every time:
> 
> 
> 
> $cnt = 1;
> 
> $replace = '"Mark$cnt"';
> 
> $s = "ab xy cd xy ef xy gh";
> 
> 
> 
> while ($s =~ s/xy/$replace/gee) { 
> 
> 	  $cnt++;
> 
> }
> 
> print $s;
> 
> 
> 
> Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
> 
> 
> 
> My understanding of the /ee modifier is that it forces the right-hand side to be evaluated every time, but somewhere in my understanding something seems to be missing. 
> 
> 
> 
> I'd be grateful if someone could point me the way.
> 
> Thanks in advance, 
> 
> 
> 
> Rob V.



On Wednesday, August 8, 2012 11:25:27 PM UTC+2, RobV wrote:
> I'm trying to do a global replace with a varying replacement string which includes a counter to count the replacements. 
> 
> The idea is this (replacing all "xy" strings):
> 
>    Source: "ab xy cd xy ef xy gh"
> 
>    Result: "ab Mark1 cd Mark2 ef Mark3 gh"
> 
> 
> 
> I read through perlre and the best I can come up with is below. Yet it doesn't do what I wanted, the replacement is identical every time:
> 
> 
> 
> $cnt = 1;
> 
> $replace = '"Mark$cnt"';
> 
> $s = "ab xy cd xy ef xy gh";
> 
> 
> 
> while ($s =~ s/xy/$replace/gee) { 
> 
> 	  $cnt++;
> 
> }
> 
> print $s;
> 
> 
> 
> Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
> 
> 
> 
> My understanding of the /ee modifier is that it forces the right-hand side to be evaluated every time, but somewhere in my understanding something seems to be missing. 
> 
> 
> 
> I'd be grateful if someone could point me the way.
> 
> Thanks in advance, 
> 
> 
> 
> Rob V.



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

Date: Wed, 8 Aug 2012 15:52:44 -0700 (PDT)
From: rob@sypron.nl
Subject: Re: Using variable in replacement expression
Message-Id: <b6bc8f58-51e8-4392-a579-f5930e89142f@googlegroups.com>

On Thursday, August 9, 2012 12:42:15 AM UTC+2, Tim McDaniel wrote:
> In article <141389db-09e3-43de-89c5-e8cb9ce8abeb@googlegroups.com>,
> 
> RobV  <rob@sypron.nl> wrote:
> 
> >I'm trying to do a global replace with a varying replacement string
> 
> >which includes a counter to count the replacements.
> 
> >The idea is this (replacing all "xy" strings):
> 
> >   Source: "ab xy cd xy ef xy gh"
> 
> >   Result: "ab Mark1 cd Mark2 ef Mark3 gh"
> 
> >
> 
> >I read through perlre and the best I can come up with is below. Yet
> 
> >it doesn't do what I wanted, the replacement is identical every time:
> 
> >
> 
> >$cnt = 1;
> 
> >$replace = '"Mark$cnt"';
> 
> >$s = "ab xy cd xy ef xy gh";
> 
> >
> 
> >while ($s =~ s/xy/$replace/gee) { 
> 
> >	  $cnt++;
> 
> >}
> 
> >print $s;
> 
> 
> 
> As a side note: even in a simple test program, it's best to keep the
> 
> discipline of
> 
>     use warnings;
> 
>     use strict;
> 
> and "my"ing all variables.
> 
> 
> 
> >Result is: "ab Mark1 cd Mark1 ef Mark1 gh"
> 
> >
> 
> >My understanding of the /ee modifier is that it forces the right-hand
> 
> >side to be evaluated every time, but somewhere in my understanding
> 
> >something seems to be missing.
> 
> 
> 
> Print $cnt after the loop.  You'll see that it's 2.  That means that
> 
> the loop iterated only once.
> 
> 
> 
> The problem is the "g" modifier.  It replaces ALL occurrences the
> 
> first time it runs.
> 
> 
> 
> "g" in general is a good idea, to prevent an infinite loop if the RHS
> 
> happened to contain the LHS (that is, if $replace contained "xy").
> 
> 
> 
> This works for me in 5.14.2:
> 
> 
> 
>     my $s = "ab xy cd xy ef xy gh\n";
> 
>     my $cnt = 0;
> 
>     $s =~ s/xy/++$cnt, "Mark$cnt"/ge;
> 
>     print $s;
> 
> 
> 
> and therefore
> 
> 
> 
>     my $s = "ab xy cd xy ef xy gh\n";
> 
>     my $cnt = 0;
> 
>     my $replace = '++$cnt, "Mark$cnt"';
> 
>     $s =~ s/xy/$replace/gee;
> 
>     print $s;
> 
> 
> 
> -- 
> 
> Tim McDaniel, tmcd@panix.com


Thanks very much. It works now!

Rob V.


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

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


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