CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
array references

 



orange
Novice

Feb 19, 2013, 4:23 AM

Post #1 of 3 (324 views)
array references Can't Post

I need to simplify this:

$servisi[0][5]=1
$servisi[1][5]=1
$servisi[2][5]=1
$servisi[3][5]=1
..

for all elements/arrays/references.
can someone please help?
10x


BillKSmith
Veteran

Feb 19, 2013, 5:09 AM

Post #2 of 3 (321 views)
Re: [orange] array references [In reply to] Can't Post

I really do not understand how you want your example generalized. This will solve your example. I hope it will get you started yourself.

Code
use strict; 
use warnings;
use Data::Dumper;
my @servisi;
$#servisi = 3;
$_->[5] = 1 for @servisi;
print Dumper \@servisi;

Good Luck,
Bill


orange
Novice

Feb 19, 2013, 5:18 AM

Post #3 of 3 (320 views)
Re: [BillKSmith] array references [In reply to] Can't Post

thank you very much, Bill.

I had tried this:

Code
                           foreach (@servisi,$ind=0) 
{
$servisi[$ind][5]=1;
$ind++;
}

but yours is much much better.


(This post was edited by orange on Feb 19, 2013, 5:18 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives