Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Common Causes for "Modification of a read-only value attempted"

by imp (Priest)
on Sep 01, 2006 at 02:58 UTC ( #570712=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    for my $x (1,2) {
      $x++;
    }
    
  2. or download this
    for (1,2) {
      chomp;
    ...
    
    @array = map  { $_++ } (1,2);
    @array = grep { $_++ } (1,2);
    
  3. or download this
    sub incr {
      $_[0]++;
    ...
    my $n = 1;
    incr($n); # good
    incr(1);  # bad
    
  4. or download this
    @array = sort { $a++ } (1,2);
    
  5. or download this
    my @bad;
    $bad[0] = [1];
    $bad[2] = [2];
    @bad = sort {$a->[0] <=> $b->[0]} @bad;
    
  6. or download this
    for (1,2) {
      my $data = prompt_user();
    ...
         # Do stuff
       }
    }
    
  7. or download this
    for (1,2) {
        while (<STDIN>) {
        }
    }
    
  8. or download this
    $_++ for (1,2);
    $_++ for (1,@array);
    @array = map {$_++} (1,@array);
    
  9. or download this
    my @array = (1,2);
    for (@array) {
      $_++;
    }
    
  10. or download this
    my ($x,$y) = (1,2);
    for ($x,$y) {
      $_++;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://570712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2014-10-21 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (106 votes), past polls