Cannot modify read-only value in while loop?

2007-01-19 Thread Richard Jones
Help. I've just stumbled upon a new one to me: my $ref = [ 1..3 ]; push @$ref, 4; print Dumper $ref as expected gives: $VAR1 = [ 1, 2, 3, 4 ]; But in a DBI context: while ( my $ref = $sth->fetchrow_arrayref() ) { # $ref is arrayref push @$ref, 1; # line xx } dies with 'Modificati

Re: Passing hash into sub routines (should i use reference?)

2007-01-19 Thread Richard Jones
Michael Alipio wrote: Hi, Suppose I have this code: #/usr/local/bin/perl use warnings; use strict; use subs 'verify'; my %where=( Gary => "Dallas", Lucy => "Exeter", Ian => "Reading", Samantha => "Oregon" ); # Then i open a logfile open FH, '<', $logfile or die "Can't open $logfile!: $!";

Re: Cannot modify read-only value in while loop?

2007-01-19 Thread Richard Jones
Xavier Noria wrote: On Jan 19, 2007, at 12:55 PM, Richard Jones wrote: while ( my $ref = $sth->fetchrow_arrayref() ) { # $ref is arrayref push @$ref, 1; # line xx } dies with 'Modification of read-only value attempted at .. line xx' Yes, that reference has a flag READONLY tu