Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

kennethk's scratchpad

by kennethk (Monsignor)
on Sep 18, 2008 at 19:23 UTC ( #712373=scratchpad: print w/ replies, xml ) Need Help??

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @data = ( {unit => 'S', value => 50, }, {unit => 'T', value => 60, }, {unit => 'Q', value => 70, }, ); # Works LOCAL_BLOCK_1: { local $data[0]{unit} = 'S'; local $data[1]{unit} = 'S'; local $data[2]{unit} = 'S'; print Dumper \@data; } # Doesn't work LOCAL_BLOCK_2: { local $data[$_]{unit} = 'S' for 0 .. $#data; print Dumper \@data; } # Doesn't work LOCAL_BLOCK_3: { local $_->{unit} = 'S' for @data; print Dumper \@data; } ## Doesn't work, fatal #LOCAL_BLOCK_4: { # local map {$_->{unit}} @data; # $_->{unit} = 'S' for @data; # # print Dumper \@data; #} print Dumper \@data;
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-11-29 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls