Conditional sorting across two arrays

2006-12-12 Thread Rinku Mahesh
Hi, I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} Here I'm looking for a sorting mechanism with the following conditions:- a. Sort 2nd Array in descending order such that it

Re: Conditional sorting across two arrays

2006-12-12 Thread Rob Dixon
Rinku Mahesh wrote: Hi, I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} Here I'm looking for a sorting mechanism with the following conditions:- a. Sort 2nd Array in descending order such that it

Re: Conditional sorting across two arrays

2006-12-12 Thread Rob Coops
Hi Rinku, Now I could try and explain this in my own words but I think this will help you a lot more. http://www.unix.org.ua/orelly/perl/advprog/ch02_02.htm What you are looking for is a very common thing, your not the first to bump into this problem :-) Regards, Rob On 12/12/06, Rinku

Re: Conditional sorting across two arrays

2006-12-12 Thread Dr.Ruud
Rinku Mahesh schreef: I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} [...] b. The values of 1st array should also change in accordance with the positions of elements of 2nd array such

Re: Conditional sorting across two arrays

2006-12-12 Thread Ovid
--- Rob Coops [EMAIL PROTECTED] wrote: Hi Rinku, Now I could try and explain this in my own words but I think this will help you a lot more. http://www.unix.org.ua/orelly/perl/advprog/ch02_02.htm What you are looking for is a very common thing, your not the first to bump into this

RE: Conditional sorting across two arrays

2006-12-12 Thread Charles K. Clarkson
Rinku Mahesh mailto:[EMAIL PROTECTED] wrote: : If the above explaination is confusing I'm looking for a way : where every element of an array can be mapped to corresponding : element of another array and as a whole both the arrays require : a sorting w.r.t. 2nd array. M.J. Dominus wrote

Re: Conditional sorting across two arrays

2006-12-12 Thread Paul
On Tue, December 12, 2006 6:25 am, Ovid wrote: --- Rob Coops [EMAIL PROTECTED] wrote: Hi Rinku, Now I could try and explain this in my own words but I think this will help you a lot more. What you are looking for is a very common thing, your not the first to bump into this problem :-)

module to calculate time difference between two

2006-12-12 Thread kilaru rajeev
Hi All, I want to calculate the time difference(hh:mm:ss) between two when they are provided with date and time. Could anyone provide the module to handle this? -- Thanks and Regards, Rajeev Kilaru Associate Charles River Team Franklin Templeton Technologies (FTT-ISC) Hyderabad Work Pone:

Re: module to calculate time difference between two

2006-12-12 Thread Mathew
kilaru rajeev wrote: Hi All, I want to calculate the time difference(hh:mm:ss) between two when they are provided with date and time. Could anyone provide the module to handle this? Maybe this can get you started: http://beta.nntp.perl.org/group/perl.datetime/2006/05/msg6342.html Mathew

Re: module to calculate time difference between two

2006-12-12 Thread D. Bolliger
kilaru rajeev am Dienstag, 12. Dezember 2006 13:22: Hi All, Hello I want to calculate the time difference(hh:mm:ss) between two when they are provided with date and time. Could anyone provide the module to handle this? There are different modules to handle date/time tasks. CPAN is a great

Re: How do I count skip the number of duplicate elements in an array

2006-12-12 Thread Peter Scott
On Mon, 11 Dec 2006 06:02:25 -0800, Rinku Mahesh wrote: - my @fields =(); my @unique_elements=(); my %seen = (); foreach my $elem (@fields) { next if $seen{ $elem }++; push (@unique_elements, $elem); } - What

declaring a zero size hash

2006-12-12 Thread Dukelow, Don
I'm trying to declare a zero size hash so a sub function can populate it and be see by all other sub's. my %loginHash(); But the use strict doesn't like it. All examples of making a hash structure is hard coded in the program or is made reading from a file. When I try to run the script all I

Re: Perl tree script

2006-12-12 Thread Jenda Krynicky
From: stic [EMAIL PROTECTED] Yeah, very very thank for help, now it`s making exactly what i want. but could you please explain what all this one line do? push @{ -d $cesta/$_ ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, $_ for grep !/\A\.\.?\z/,readdir $OBSAH; I`m absolute begginer in

Re: declaring a zero size hash

2006-12-12 Thread Jeff Pang
Just write it like: my %loginHash = (); This should work. -Original Message- From: Dukelow, Don [EMAIL PROTECTED] Sent: Dec 13, 2006 12:23 AM To: beginners@perl.org Subject: declaring a zero size hash I'm trying to declare a zero size hash so a sub function can populate it and be see

Re: declaring a zero size hash

2006-12-12 Thread Adriano Ferreira
On 12/12/06, Dukelow, Don [EMAIL PROTECTED] wrote: I'm trying to declare a zero size hash so a sub function can populate it and be see by all other sub's. my %loginHash(); my %loginHash; should be enough. But the use strict doesn't like it. It is not use strict that does not like it. It

Re: declaring a zero size hash

2006-12-12 Thread Tom Phoenix
On 12/12/06, Dukelow, Don [EMAIL PROTECTED] wrote: I'm trying to declare a zero size hash so a sub function can populate it and be see by all other sub's. my %loginHash(); Maybe you mean this? my %loginHash = (); But every new variable (which is what 'my' is declaring) starts out empty,

RE: declaring a zero size hash

2006-12-12 Thread Helliwell, Kim
I think you need to do: my %loginhash = {}; Kim Helliwell LSI Logic Corporation Work: 408 433 8475 Cell: 408 832 5365 [EMAIL PROTECTED] Please Note: My email address changed to [EMAIL PROTECTED] on Oct 14. The old email address ([EMAIL PROTECTED]) will stop working after Jan 15, 2007. Please

Re: declaring a zero size hash

2006-12-12 Thread Adriano Ferreira
On 12/12/06, Helliwell, Kim [EMAIL PROTECTED] wrote: I think you need to do: my %loginhash = {}; That's not right. {} is a hash ref, not a hash. It stands for a scalar value. When you do that my %h = {} or, for the same result, my %h = 1; my %h = abacate; you end with a hash

RE: Perl create tcp connections

2006-12-12 Thread Ron McKeever
Thanks for the updates, I understand. Then perhaps someone can help me get this script to set the tcp to SYN_SENT on 100 ports: #!/usr/bin/perl use Socket; $count=3500; while ($count3601) { $count++; $addr=sockaddr_in($count,inet_aton('localhost'));

Re: Perl create tcp connections

2006-12-12 Thread Lawrence Statton XE2/N1GAK
Take a step back -- what are you trying to accomplish? -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is

reg exp

2006-12-12 Thread Derek B. Smith
I have a string like so: /home/dbsmith/passwd.oftappp1.hpux and I need to parse out oftappp1 and hpux. I have tried to use substr and and regexp with =~. Here is what I have tried, but need some help cause I am getting frustrated. NOTE: strings after passwd are variable in length, could be 3-10

Re: reg exp

2006-12-12 Thread D. Bolliger
Derek B. Smith am Dienstag, 12. Dezember 2006 23:19: I have a string like so: /home/dbsmith/passwd.oftappp1.hpux and I need to parse out oftappp1 and hpux. I have tried to use substr and and regexp with =~. Here is what I have tried, but need some help cause I am getting frustrated.

Re: reg exp

2006-12-12 Thread John W. Krahn
Derek B. Smith wrote: I have a string like so: /home/dbsmith/passwd.oftappp1.hpux and I need to parse out oftappp1 and hpux. I have tried to use substr and and regexp with =~. Here is what I have tried, but need some help cause I am getting frustrated. NOTE: strings after passwd are

Re: reg exp

2006-12-12 Thread Lawrence Statton XE2/N1GAK
If you're dealing with variable length strings, separated by some kind of character, then regexp is the tool you want, not substr. This snippet will work so long as hostname and platformname are made up of \w ... if not, substitute in an appropriate character class. #!/usr/bin/perl use strict;

Re: reg exp

2006-12-12 Thread I . B .
or just: my $filename=/home/dbsmith/passwd.duby02.linux; my ($pass,$hostname,$platform)=split /\./, $filename; ~i On 12/12/06, Lawrence Statton XE2/N1GAK [EMAIL PROTECTED] wrote: If you're dealing with variable length strings, separated by some kind of character, then regexp is the tool you

Re: reg exp

2006-12-12 Thread Derek B. Smith
--- D. Bolliger [EMAIL PROTECTED] wrote: Derek B. Smith am Dienstag, 12. Dezember 2006 23:19: I have a string like so: /home/dbsmith/passwd.oftappp1.hpux and I need to parse out oftappp1 and hpux. I have tried to use substr and and regexp with =~. Here is what I have tried, but

extracting common substrings...

2006-12-12 Thread Helliwell, Kim
Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? I've been looking for such a beast on CPAN, but no luck so far. If not, I guess I have to write it myself... Any help appreciated. Kim

Re: extracting common substrings...

2006-12-12 Thread Tom Phoenix
On 12/12/06, Helliwell, Kim [EMAIL PROTECTED] wrote: Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? You want the longest possible common substring? Or all of the longest ones, if there's more

Re: extracting common substrings...

2006-12-12 Thread John W. Krahn
Helliwell, Kim wrote: Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? I've been looking for such a beast on CPAN, but no luck so far. Perhaps this is what you require:

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
Helliwell, Kim am Dienstag, 12. Dezember 2006 21:56: Is there a function (perhaps in a library module) that would take two strings and return the common substring (if any) contained in the arguments? I've been looking for such a beast on CPAN, but no luck so far. If not, I guess I have to

Re: Re: extracting common substrings...

2006-12-12 Thread Tom Phoenix
On 12/12/06, D. Bolliger [EMAIL PROTECTED] wrote: $found{$1}++ for ($s2=~/($search)/g); # although count not used below Didn't $search just come from the data? It's a string, not a pattern. If it's got any metacharacters, it could break your pattern, or worse. Cheers! --Tom Phoenix

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
Tom Phoenix am Mittwoch, 13. Dezember 2006 02:32: On 12/12/06, D. Bolliger [EMAIL PROTECTED] wrote: $found{$1}++ for ($s2=~/($search)/g); # although count not used below Didn't $search just come from the data? It's a string, not a pattern. If it's got any metacharacters, it could

Re: extracting common substrings...

2006-12-12 Thread D. Bolliger
D. Bolliger am Mittwoch, 13. Dezember 2006 02:25: Sorry for answering my own post... [snipped] The script contains a testcase with long strings, it takes 1.2 secs on my old machine (the test case is certainly not a worst case scenario). [snipped] ### Test case: my $pat=join '', 'hello' x

Re: Conditional sorting across two arrays

2006-12-12 Thread Mumia W.
On 12/12/2006 04:00 AM, Rinku Mahesh wrote: Hi, I've two arrays of same depth (let it be 6) 1st Array:- @unique {11 , 23, 44, 66, 900, 1009} 2nd Array:- @occ_count {2, 77, 22, 2, 77,29} Here I'm looking for a sorting mechanism with the following conditions:- a.

Re: module to calculate time difference between two

2006-12-12 Thread Mumia W.
On 12/12/2006 06:35 AM, Mathew wrote: Maybe this can get you started: http://beta.nntp.perl.org/group/perl.datetime/2006/05/msg6342.html Mathew What is beta.nntp.perl.org ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: module to calculate time difference between two

2006-12-12 Thread Mathew Snyder
Mumia W. wrote: On 12/12/2006 06:35 AM, Mathew wrote: Maybe this can get you started: http://beta.nntp.perl.org/group/perl.datetime/2006/05/msg6342.html Mathew What is beta.nntp.perl.org ? I'm it is an archive of perl.org mailing lists. For instance