in reply to a 'with' statement for perl

It seems to me that the first part, using with to topicalize is exactly what for does:

#!/usr/bin/perl -w use strict; my $foo = "a string"; print "before with: $foo\n"; for($foo) { s/a /not a /; } print "after with: $foo\n";

I believe that's indeed one of the reasons for the use of for as a keyword, instead or just foreach.

Replies are listed 'Best First'.
Re: Re: a 'with' statement for perl
by broquaint (Abbot) on Apr 25, 2003 at 12:05 UTC
    It seems to me that the first part, using with to topicalize is exactly what for does ...
    It is indeed, but for's behaviour isn't obvious to many programmers coming from other languages (and yes, I know it's clearly documented in perlsyn). I should possibly also mention in the description that it was inspired out of a CB conversation, which explains away the obvious redundancy ;)
    HTH

    _________
    broquaint