Melly has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I'm having trouble with the following code. I'm using __DATA__ for this, but originally ran into the problem with an external file. Basically, the act of reading from a handle seems to be nuking the content of my array of arrays, and I get a "use of uninitialized value..." once I've hit __DATA__.
Here's the code:
use strict; use warnings; my @testarray; push @testarray, [10,20],[30,40]; print "ok...\n"; print "$#testarray\n"; print "$testarray[0]->[0]\n\n"; foreach(@testarray){ while(<DATA>){ } } print "Nope...\n"; print "$#testarray\n"; print "$testarray[0]->[0]\n"; __DATA__ hello world
And here's the output:
ok... 1 10 Nope... 1 Use of uninitialized value in concatenation (.) or string at test_02.p +l line 17, <DATA> line 2.
Tom Melly, pm (at) cursingmaggot (stop) co (stop) ukmap{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Arrays and Handles Problem (updated)
by haukex (Archbishop) on May 02, 2019 at 11:57 UTC | |
|
Re: Arrays and Handles Problem
by holli (Abbot) on May 02, 2019 at 11:52 UTC | |
by Melly (Chaplain) on May 02, 2019 at 12:28 UTC | |
by haukex (Archbishop) on May 02, 2019 at 12:31 UTC |