Ed [EMAIL PROTECTED] asked:
[...]
I'm reading from a file and constructing an array of arrays.
Here's an example of what's in the file:
net localgroup Field Aidan /ADD
[...]
I want to sort the lines in the file by the 3rd column
(Field, Internal, CM, DocAdmin)
If you're not particularly
Ed wrote:
: my @lineArray;
: while(F)
: {
: # if the line is a net localgroup line add it to the array
: if( $_ =~ $s_criteria )
You probably should be testing against a regular expression.
if ( $_ =~ /$s_criteria/ )
Or just:
if ( /$s_criteria/ )
:
Ed wrote:
I want to sort the lines in the file by the 3rd column (Field,
Internal, CM, DocAdmin)
Since Perl doesn't really support multidimensional arrays but instead
uses references, something like this should work:
sort { $$a[2] cmp $$b[2] } @array;
This is more or less like the typical
Thomas Bätzler wrote:
Ed [EMAIL PROTECTED] asked:
push( @lineArray, @_ ); ---no it's an array of arrays.
This will append all the items in @_ to @lineArray.
You shoul've said push( @lineArray, [EMAIL PROTECTED] ); instead.
No he shouldn't have. @_ is a global variable so
Charles K. Clarkson wrote:
Ed wrote:
: push( @lineArray, @_ ); ---no it's an array of arrays.
An array of arrays is a short name for an array of array
references. Array elements can only hold scalar values and arrays
are not scalars. References to arrays are scalars.
I'm still hobbled by my thinking in C problem so I'm looking for a way
to do this.
I'm reading from a file and constructing an array of arrays.
Here's an example of what's in the file:
net localgroup Field Aidan /ADD
net localgroup Internal Aidan /ADD
net localgroup CM Aidan /ADD
net localgroup