Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Changing data within a matrix

by nadadogg (Acolyte)
on Feb 11, 2004 at 21:18 UTC ( [id://328386]=perlquestion: print w/replies, xml ) Need Help??

nadadogg has asked for the wisdom of the Perl Monks concerning the following question:

I have a snippet of code I'm working on, I'm decent with perl, but as I've always had to learn in a hurry, my all-around knowledge is lacking. What I have here is a matrix of data, and I need to change the first field in each row into undef so that I can continue with the rest of the script
sub indextime{ open FILE, "<p2cash.prn"; open OUTP, ">p2cashmast.txt"; select STDOUT; undef (@matrix); while (<FILE>){ push @matrix, [split]; } $storenum = $matrix[0][0]; $date = $matrix[0][1]; #approx line 100 print "date $date \n "; print "store$storenum \n "; #@matrix[0] = undef; #@matrix[1] = undef; #@matrix[2] = undef; #@matrix[3] = undef; select OUTP; for $i (6.. ($#matrix-1)){ #$matrix[i][0] = $storenum; $matrix[i][0] = undef; print "@{$matrix[$i]} $storenum $date\n"; } }
I tried the $matrix[i][0] = undef, but that didn't do it.

Replies are listed 'Best First'.
Re: Changing data within a matrix
by jeffa (Bishop) on Feb 11, 2004 at 21:25 UTC
      That did the trick. Thanks a bunch
Re: Changing data within a matrix
by kelan (Deacon) on Feb 11, 2004 at 22:26 UTC

    The reason $matrix[i][0] didn't work is because you forgot the $ in front of i. Try it this way:

    $matrix[$i][0] = undef;
    strict or warnings would have tipped you off to this one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://328386]
Approved by ybiC
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found