Re: Testing whether an array has any elements in it

2004-08-05 Thread John W. Krahn
Edward Wijaya wrote: Hi, Hello, Is there any efficient way to do that? if ( @array ) { print "[EMAIL PROTECTED] has elements.\n"; } else { print "[EMAIL PROTECTED] is empty.\n"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: Testing whether an array has any elements in it

2004-08-05 Thread Randy W. Sims
On 8/5/2004 11:39 PM, Edward Wijaya wrote: Hi, Is there any efficient way to do that? scalar( @array ) Returns the number of elements in an array. It is a constant time operation; the number of elements is stored as part of the internal data structure, so it's just a lookup. -- To unsubscribe, e

Re: How to pass two arrays as arg in a subroutine?

2004-08-05 Thread Edward Wijaya
Thanks so much Kamal, your explanation is very clear and complete. It works now. I learnt a great deal from it. Regards Edward WIJAYA Hope this is useful for you. For more on references go through "perldoc perlref" With Best regards, R. Kamal Raj Guptha. -- To unsubscribe, e-mail: [EMAIL PROTECTE

Testing whether an array has any elements in it

2004-08-05 Thread Edward Wijaya
Hi, Is there any efficient way to do that? Regards, Edward WIJAYA SINGAPORE -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: Gunnar Hjalmarsson wrote: Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky...

RE: Testing for empty value

2004-08-05 Thread Charles K. Clarkson
From: mike wrote: : I have the following code : : print "date times",@date,br; : if ($ti1){ : print "time 1 is not empty"; : } : else { : print "time 1 is empty"; : } : : If there is a value it works but not if there isn't : ie: if there is a value it prints "time 1 is

Re: Testing for empty value

2004-08-05 Thread Randy W. Sims
On 8/5/2004 6:23 PM, Jenda Krynicky wrote: From: mike <[EMAIL PROTECTED]> I have the following code print "date times",@date,br; if ($ti1){ print "time 1 is not empty"; } else { print "time 1 is empty"; } If there is a value it works but not if there isn't ie: if there is a value it prints "time 1

Re: Testing for empty value

2004-08-05 Thread Jenda Krynicky
From: mike <[EMAIL PROTECTED]> > I have the following code > > print "date times",@date,br; > if ($ti1){ > print "time 1 is not empty"; > } > else { > print "time 1 is empty"; > } > > If there is a value it works but not if there isn't ie: > if there is a value it prints "time 1 is not empty", bu

Re: Sorting an array of hashes

2004-08-05 Thread Randy W. Sims
On 8/5/2004 5:18 PM, Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to sort a simple array. I know how to sort a hash by the keys. Could someone kindly point me to the documentation on sorting arrays o

RE: Sorting an array of hashes

2004-08-05 Thread Moon, John
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to

Testing for empty value

2004-08-05 Thread mike
I have the following code print "date times",@date,br; if ($ti1){ print "time 1 is not empty"; } else { print "time 1 is empty"; } If there is a value it works but not if there isn't ie: if there is a value it prints "time 1 is not empty", but if there is not nothing comes out anyone any ideas?

RE: Sorting an array of hashes

2004-08-05 Thread Chris Devers
On Thu, 5 Aug 2004, Chris Mortimore wrote: Gunnar Hjalmarsson wrote: > Chris Mortimore wrote: >> I want to sort an AoH. Not each hash by its keys, but the array by >> the value of one of the keys in each hash. > > The value of one of the keys? If you don't know *which* key in > respective hash, th

RE : cryptic error messages in modules

2004-08-05 Thread Jose Nyimi
> -Message d'origine- > De : news [mailto:[EMAIL PROTECTED] De la part de Christopher J. Bottaro > Envoyé : jeudi 5 août 2004 19:39 > À : [EMAIL PROTECTED] > Objet : cryptic error messages in modules > > package My::Class; > use strict; > use warnings; > use Class::Struct; > use IO::File

RE: Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
Chris Mortimore wrote: > I want to sort an AoH. Not each hash by its keys, but the array by > the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.g

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc

Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
I want to sort an AoH. Not each hash by its keys, but the array by the value of one of the keys in each hash. I know how to sort a simple array. I know how to sort a hash by the keys. Could someone kindly point me to the documentation on sorting arrays of hashes? Thank you! Chris. >>>-> <-

Re: ref() is not reporting correctly

2004-08-05 Thread Jenda Krynicky
From: Rich Fernandez <[EMAIL PROTECTED]> > I have a hash which looks something like this: > %hash = ( foo => 'a', bar => 'b', filespec => "$filespec"); > > I also have a function which includes the following code: > ># Figure out if we were passed a filename or an array ref >if ( exists

ref() is not reporting correctly

2004-08-05 Thread Rich Fernandez
I have a hash which looks something like this: %hash = ( foo => 'a', bar => 'b', filespec => "$filespec"); I also have a function which includes the following code: # Figure out if we were passed a filename or an array ref if ( exists $info -> {filespec} ) { $filespec = $info ->

cryptic error messages in modules

2004-08-05 Thread Christopher J. Bottaro
package My::Class; use strict; use warnings; use Class::Struct; use IO::File; struct MyStruct => { f1 => '$', f2 => '$' }; sub new { my ($class, $ifname) = @_; my $s = {}; $class = ref($class) || $class; bless ($s, $class); $s->{FILE} = new

RE: using Class::Struct in a module

2004-08-05 Thread Christopher J. Bottaro
thank you. i guess when i was saying 'my $s = new FHEAD', it was calling the new() in the current package. changing it to 'my $s = FHEAD->new()' forces it to use FHEAD's new() method. NYIMI Jose (BMB) wrote: > > >> -Original Message- >> From: news [mailto:[EMAIL PROTECTED] On Behalf O

RE: Sorting HTML tables

2004-08-05 Thread Paul Harwood
The table is fairly complicated. I'll take a look at those modules though. Thanks! -Original Message- From: Chris Devers [mailto:[EMAIL PROTECTED] Posted At: Wednesday, August 04, 2004 5:03 PM Posted To: Perl Conversation: Sorting HTML tables Subject: Re: Sorting HTML tables On Wed, 4 Au

Re: How to pass two arrays as arg in a subroutine?

2004-08-05 Thread WilliamGunther
Have them pass the arrays as a reference. For example: @array1 = (1, 2, 3, 4, 5); @array2 = (6, 7, 8, 9, 10); mysub([EMAIL PROTECTED],[EMAIL PROTECTED]); sub mysub{ my ($array1, $array2) = @_; #process @{$array1} #process @{$array2} etc return @array3; } Look into perl

RE: floating point convertion

2004-08-05 Thread Charles K. Clarkson
From: Mark Cohen wrote: : Hello , : : I have a transferred a file from an IBM mainframe : to a windows platform that I need to analyse. The : file contains an 8 byte floating point hexadecimal : representaion 44FE8800. : : This should be converted to the number

RE: integrating C++ apps with perl

2004-08-05 Thread NYIMI Jose (BMB)
> -Original Message- > From: anon ymous [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 05, 2004 12:17 PM > To: [EMAIL PROTECTED] > Subject: integrating C++ apps with perl > > > Hi, > > I've never used perl before, and I have a gut feeling that it > might be > the tool to fit a r

RE: Determining Odd and Even Numbers

2004-08-05 Thread kamal.gupta
Hi Jenda, That was amazing. It was a good learning for me, and I never knew about Benchmark... Sorry for that... My reasoning was absolutely logical and nothing systematical Thanks for the great reasoning which was real real systematical. But the same script in my environment gives me

RE: using Class::Struct in a module

2004-08-05 Thread NYIMI Jose \(BMB\)
> -Original Message- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of > Christopher J. Bottaro > Sent: Thursday, August 05, 2004 12:35 AM > To: [EMAIL PROTECTED] > Subject: using Class::Struct in a module > > > package My::Module; > use Class::Struct; use strict; use warnings; >

Re: doubt in Definition of sub routine.

2004-08-05 Thread Jose Alves de Castro
On Thu, 2004-08-05 at 11:07, [EMAIL PROTECTED] wrote: > Hi All, Hi > I am using code written by some one else. I didn't understand the difference > between these subroutines, the way they were defined. > > 1. sub addToLog { Some code } Any specific reason where we should > not use braces

Re: doubt in Definition of sub routine.

2004-08-05 Thread Gunnar Hjalmarsson
Anand V wrote: I am using code written by some one else. I didn't understand the difference between these subroutines, the way they were defined. 1. sub addToLog { Some code }Any specific reason where we should not use braces ?? 2. sub displayEnv( ) { " }Any specific reason why

RE: How to pass two arrays as arg in a subroutine?

2004-08-05 Thread kamal.gupta
Hi, Whenever you pass two arrays (or any number of arrays for that matter) as arguments to a function, what happens is they get flattened and become a single list and then it is assigned to @_. So when U say > > my (@array1, @array2) = @_; # is this correct? How do I do it? > @array1 has

integrating C++ apps with perl

2004-08-05 Thread anon ymous
Hi, I've never used perl before, and I have a gut feeling that it might be the tool to fit a requirement I have, but I'm not sure. If anyone can confirm that I'm not barking up the wrong forest, then that'd be great. I have a C++ application that's mainly on unix, but it's designed to be platfo

doubt in Definition of sub routine.

2004-08-05 Thread Anand . V
Hi All, I am using code written by some one else. I didn't understand the difference between these subroutines, the way they were defined. 1. sub addToLog { Some code }Any specific reason where we should not use braces ?? 2. sub displayEnv( ) { " }Any specific reason why

How to pass two arrays as arg in a subroutine?

2004-08-05 Thread Edward Wijaya
Hi, I have a subroutine that take 2 arrays as argument. I dont' know how to construct it? sub mysub{ my (@array1, @array2) = @_; # is this correct? How do I do it? #process @array1 #process @array2 etc return @array3; } Please advice. Thanks so much for your time. Regards, Edwa