Sponsored Content
Top Forums Shell Programming and Scripting PERL: How do i print an associative matrix? Post 302138025 by foo.bar on Friday 28th of September 2007 09:06:53 AM
Old 09-28-2007
Yes they are strings. Thank you very much cbkihong!

The code you posted nearly works (there were some typing errors). I post the correct code:

Code:
foreach $key1 (keys %matrix) {
        foreach $key2 (keys %{%matrix->{$key1}}) {
                print "\$matrix{$key1}{$key2} = $matrix{$key1}{$key2},  ";                            
                } 
        print"\n";                                                                                   
        }

Hope this will help sombody else.

Cheers,

Sergio
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Sorting an associative array

Hi, When using sort on an associative array: foreach $key (sort(keys(%opalfabet))){ $value = $opalfabet{$key}; $result .= $value; } How does it handle double values? It seems to me that it removes them, is that true? If so, is there a way to get... (2 Replies)
Discussion started by: tine
2 Replies

2. Shell Programming and Scripting

PERL: How do I get both sizes of a matrix?

Hi everybody, I have a matrix called @matrix dinamically built in PERL, so I don't know its exact sizes. It is a 2-dimensional matrix, so its elements are for example: $matrix $matrix $matrix $matrix $matrix etc... I know i can get the number of the rows of the matrix with the... (2 Replies)
Discussion started by: foo.bar
2 Replies

3. Shell Programming and Scripting

Perl- matrix problem

A C G T - A 5 -4 -4 -4 -5 C -4 5 -4 -4 -5 G -4 -4 5 -4 -5 T -4 -4 -4 5 -5 - -5 -5 -5 -5 0 So lets say I have a matrix which looks something like (above). Its basically a scoring matrix. the numbers are... (2 Replies)
Discussion started by: aj05
2 Replies

4. Shell Programming and Scripting

Invert Matrix of Data - Perl

I have columnar data in arrays perl, Example - @a = (1,2,3); @array1 = (A,B,C); @array2 = (D,E,F); @array3 = (I,R,T); I want the data to be formatted and printed as 1 A D I 2 B E F 3 C F T and so on... (8 Replies)
Discussion started by: dinjo_jo
8 Replies

5. Shell Programming and Scripting

BASH: print matrix from single array

I am creating a report in groff and need to format data from a file into a table cell. Sample data: dador,173323,bpt,jsp,39030013338878,1 dador,173323,brew,jsp,39030013338860,1 dador,173323,brew,jsp,39030013339447,1 dador,173323,brew,jsp,39030013339538,1 I would like to build a table... (12 Replies)
Discussion started by: Bubnoff
12 Replies

6. Programming

Matrix addition - Perl - PDL

Hi All, I have a question. I need to add 3 matrices of size 2000 x 2000. (i.e) 2000 rows and 2000 columns using Perl::PDL module. I used the following perl script #!/usr/bin/perl -w use strict; use warnings; use PDL; use PDL::Matrix; if ( @ARGV != 3 ) { die 'Two matrix files are... (1 Reply)
Discussion started by: Fredrick
1 Replies

7. Shell Programming and Scripting

Perl- creating a matrix from a 3 column file

Dear all, I'm new in perl scripting and I'm trying to creating a matrix from a 3 column file sorting data in a particular manner. In the final matrix I need to have the first column "IDs" on the header of the columns and the second column values on the header of each row. And the value fo the... (2 Replies)
Discussion started by: gabrysfe
2 Replies

8. Shell Programming and Scripting

Randomization a matrix - perl / Shell

Hello all, I have a tricky question! (at least for me it is!). I'll try to explain it carefully here. Hope you can help me solving the whole or even parts of it! Here it is: I have a big input 0\1 table as a very simplified one is shown below: (The last row and column are the sum and... (0 Replies)
Discussion started by: @man
0 Replies

9. Shell Programming and Scripting

How to print median values of matrix -awk?

I use the following script to print the sum and how could I extend this to print medians instead? thanks name s1 s2 s3 s4 g1 2 8 6 5 g1 5 7 9 9 g1 6 7 8 9 g2 8 8 8 8 g2 7 7 7 7 g2 10 10 10 10 g3 3 12 1 24 g3 5 5 24 48 g3 12 3 12 12 g3 2 3 3 3 output name s1 s2 s3 s4 g1 5 7 8 9... (5 Replies)
Discussion started by: quincyjones
5 Replies
Pango::Matrix(3)					User Contributed Perl Documentation					  Pango::Matrix(3)

NAME
Pango::Matrix HIERARCHY
Glib::Boxed +----Pango::Matrix METHODS
matrix = Pango::Matrix->new ($xx=1., $xy=0., $yx=0., $yy=1., $x0=0., $y0=0.) o $xx (double) o $xy (double) o $yx (double) o $yy (double) o $x0 (double) o $y0 (double) $matrix->concat ($new_matrix) o $new_matrix (Pango::Matrix) $matrix->rotate ($degrees) o $degrees (double) $matrix->scale ($scale_x, $scale_y) o $scale_x (double) o $scale_y (double) (dx, dy) = $matrix->transform_distance ($dx, $dy) o $dx (double) o $dy (double) Since: pango 1.16 array reference = $matrix->transform_pixel_rectangle ($rect) o $rect (array reference) Since: pango 1.16 (x, y) = $matrix->transform_point ($x, $y) o $x (double) o $y (double) Since: pango 1.16 array reference = $matrix->transform_rectangle ($rect) o $rect (array reference) Since: pango 1.16 $matrix->translate ($tx, $ty) o $tx (double) o $ty (double) double = $matrix->x0 ($new) o $new (double) double = $matrix->xx ($new=0) o $new (double) double = $matrix->xy ($new) o $new (double) double = $matrix->y0 ($new) o $new (double) double = $matrix->yx ($new) o $new (double) double = $matrix->yy ($new) o $new (double) SEE ALSO
Pango, Glib::Boxed COPYRIGHT
Copyright (C) 2003-2009 by the gtk2-perl team. This software is licensed under the LGPL. See Pango for a full notice. perl v5.12.1 2010-07-05 Pango::Matrix(3)
All times are GMT -4. The time now is 11:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy