On Tue, 04 Dec 2007, Justin Allegakoen wrote:
> --8<---
> Note that you can have a lexical $_ in 5.10:
>
> foreach my $_ ( @foo ) {
>s/SID/12345/;
> }
> --8<---
>
> A! Why is that considered a good feature to add to 5.1
--8<---
Note that you can have a lexical $_ in 5.10:
foreach my $_ ( @foo ) {
s/SID/12345/;
}
--8<---
A! Why is that considered a good feature to add to 5.10?
Sure scoping and all, but do the other perlvars behave the s
--8<---
Note that you can have a lexical $_ in 5.10:
foreach my $_ ( @foo ) {
s/SID/12345/;
}
--8<---
A! Why is that considered a good feature to add to 5.10?
Sure scoping and all, but do the other perlvars behave the s
On Tue, 04 Dec 2007, [EMAIL PROTECTED] wrote:
> It's also a cautionary tale - if you're using the default "$_" in for
> loops, you can munge your original data.
> foreach my $foo ( @foo ) {
>$foo =~ s/SID/12345/;
> }
>
> this doesn't mess w/ @foo.
That is not correct; it will still modify @fo
> English to perl translation:
s/SID/12345/ for values %foo;
Nice - this takes advantage of the fact that $_ here is a reference to the
actual value of the hash so that the subst. works directly on the hash.
The same fact works for arrays too
@foo = ('abc/SID/def', 'bcd/SID/fgh', 'hjk/SID/op
my %foo = ( '01' => 'abc/SID/def',
'02' => 'bcd/SID/fgh',
'03' => 'hjk/SID/opq' );
to
$foo{'01'} = 'abc/12345/def';
$foo{'02'} = 'bcd/12345/fgh';
$foo{'03'} = 'hjk/12345/opq';
$foo{$_} =~ s/SID/12345/ for keys %foo;
a
Andy Bach
Systems
You said: "I want to replace the text 'SID' in each value of the hash with the
text '12345'".
English to perl translation:
s/SID/12345/ for values %foo;
Cheers,
-Jan
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: December 4, 2007 11:56 AM
To
William,
That's what I was looking for! Thanks a heap!!
Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150
Let us permit nature to have her way; she understands her business better
than we do. -- Michel de Montaigne___
ActivePerl maili
Gurus,
I'm embarrassed to have to ask this, but my books don't mention it, and
neither does perldoc. I'm looking for a way to do a substitution to all
values of a hash in one line, something using, oh, grep, or map... What I
want to do is change the values of this hash:
my %foo = ( '01' => '
Thanks to all who answered, but Mr. Dubos provided the guts of the
question--he sent some source code that explained it all.
Thanks again!
Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150
Let us permit nature to have her way; she understands her business better
than we do. --
Sean Tobin <> wrote:
> Could you clarify a bit more on what you mean by hash quality and
> expected comparisons? I took a look at the devel::peek module,
> specifically the outputs of its dump function and I couldn't find
> what you were looking for. It sounds like you are attempting to
> implement
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 03 December 2007 18:28
To: activeperl@listserv.ActiveState.com
Subject: "Quality Percentage" of hashes as reported by Devel::Peek
> Gurus,
>
> I tried directing this query to the module's author, but the e-mai
12 matches
Mail list logo