in reply to Re: Arrays and Handles Problem
in thread Arrays and Handles Problem

Yes, __DATA__ is a bit of a red herring, since originally it was multiple reads of an external text file.

That aside, thanks all for the explanation (and the fix). I must admit I thought I'd tried the solution already, but obviously not... also, I thought it was okay to use multiple nested instances of $_, and that each was local to its block, but clearly not...

map{$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
Tom Melly, pm (at) cursingmaggot (stop) co (stop) uk

Replies are listed 'Best First'.
Re^3: Arrays and Handles Problem
by haukex (Archbishop) on May 02, 2019 at 12:31 UTC
    I thought it was okay to use multiple nested instances of $_, and that each was local to its block, but clearly not...

    That's true for foreach, but not while (<>):

    use warnings; use strict; use Data::Dump; $_ = "foo"; for ("x","y") { dd $_; } dd $_; while (<DATA>) { dd $_; } dd $_; __DATA__ hello

    Output:

    "x" "y" "foo" "hello\n" undef