The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
matrix inverse (awk) vesyyr Shell Programming and Scripting 0 12-14-2007 03:18 PM
need help-matrix inverse (awk) vesyyr UNIX for Dummies Questions & Answers 0 12-14-2007 02:44 PM
PERL: How do i print an associative matrix? foo.bar Shell Programming and Scripting 2 09-28-2007 09:06 AM
Regarding Dot Matrix Printing aman_mlt Linux 0 02-23-2006 01:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2007
foo.bar foo.bar is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 5
Smile 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[0][0]
$matrix[0][1]
$matrix[1][0]
$matrix[1][1]
$matrix[2][0]
etc...

I know i can get the number of the rows of the matrix with the commands:

$#matrix
scalar @matrix
$n_rows = @matrix

but I don't know how to get the number of the colums of the matrix!
I tried several ways like:

$#matrix[0]
scalar @matrix[0]
$n_cols = @matrix[0]

but they haven't worked.

Can someone help me please? Thank you in advance,

Sergio.
  #2 (permalink)  
Old 09-26-2007
kahuna's Avatar
kahuna kahuna is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 149
Although it's valid only for a column 0. try
Code:
$#{$matrix[0]}
scalar @{$matrix[0]}
$n_cols = @{$matrix[0]}
  #3 (permalink)  
Old 09-26-2007
foo.bar foo.bar is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 5
Great! It works! I just needed the {} brackets! Thank you so much kahuna
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0