|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
hello I want to know how to push Double Dimensional Array values?
Code:
#!/usr/bin/perl -w # For Single Array Pushing.. push @single_arr, $values; # -- For Double Dimension Array pushing ??? ## push @single_arr[0], $values; How to push Double Dimension Array values? Thanks in advance
__________________
I will try my best !!!
|
|
#2
|
||||
|
||||
|
You can push array references into an array:
Code:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array; push @array, [qw/one two thee four/]; or you can push values into a specific location in an array: Code:
push @{$array[1]}, 'a value';
push @{$array[2]}, [qw/five six/];
print Dumper \@array;
Result: Code:
$VAR1 = [
[
'one',
'two',
'thee',
'four'
],
[
'a value'
],
[
[
'five',
'six'
]
]
];
Note: you can only push into specific array locations if those locations are undefined or already contain an array reference. Otherwise, you will have to make an assignment instead to overwrite the existing value. |
|
#3
|
||||
|
||||
|
to push into a multi-dimensional array:
push @{$array_ref[0]},$values; but how you write the code depends on how your multi-dimensional array was originally created. If you used a reference to an array to begin with you would write it like this: push @{$array_ref->[1]},$values; |
|
#4
|
||||
|
||||
|
Thanks a lot..
all are working.. fine ![]() Thanks to all of them ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > How to push double Array ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|