Match Hash Key's with Array elements

2013-12-13 Thread jet speed
Dear All, I have sample code below, i am trying print the matching array element values sorted in the hash. As you would notice only one of the array element x1259 will print its value IDT stored in the hash. Please could you advice how can i get rest of the array elements matched in the hash

Re: Match Hash Key's with Array elements

2013-12-13 Thread Shaji Kalidasan
element x1259 will print its value IDT stored in the hash. Please could you advice how can i get rest of the array elements matched in the hash example 1439 in array element needs to print its value as IDT, currently its not printing becase the key sorted in hash is 187333591439 . is there a way

Re: Match Hash Key's with Array elements

2013-12-13 Thread Uri Guttman
On 12/13/2013 07:43 AM, Shaji Kalidasan wrote: Greetings, Here is one way to do it. Please note that I have retained your variable naming conventions and style instead of inventing my own. [code] use strict; use warnings; my %complex_hash; my @ex = qw / 5326 2041 1391 1439 x1259 /; open

Re: Match Hash Key's with Array elements

2013-12-13 Thread Shawn H Corey
On Fri, 13 Dec 2013 10:01:13 -0500 Uri Guttman u...@stemsystems.com wrote: open my $fh, , fullhost.txt or die $!; while ($fh) { while( my $line = $fh ) { chomp; chomp $line; my $line = $_; no need to copy $_ as the while did it. -- Don't stop where the ink

Re: Match Hash Key's with Array elements

2013-12-13 Thread Uri Guttman
On 12/13/2013 10:09 AM, Shawn H Corey wrote: On Fri, 13 Dec 2013 10:01:13 -0500 Uri Guttman u...@stemsystems.com wrote: open my $fh, , fullhost.txt or die $!; while ($fh) { while( my $line = $fh ) { chomp; chomp $line; yep! uri -- Uri Guttman - The Perl Hunter The Best

Re: Match Hash Key's with Array elements

2013-12-13 Thread Shaji Kalidasan
Greetings, Thanks a bunch Uri and Shawn for providing valuable inputs. Here is the optimized code after corrections (based on inputs from Uri and Shawn) [code] use strict; use warnings; my %complex_hash;   my @ex = qw / 5326 2041 1391 1439  x1259 /;   open my $fh, , fullhost.txt or die $!;

Re: Match Hash Key's with Array elements

2013-12-13 Thread Uri Guttman
On 12/13/2013 10:21 AM, Shaji Kalidasan wrote: Greetings, Thanks a bunch Uri and Shawn for providing valuable inputs. Here is the optimized code after corrections (based on inputs from Uri and Shawn) [code] use strict; use warnings; my %complex_hash; my @ex = qw / 5326 2041 1391 1439

Re: Match Hash Key's with Array elements

2013-12-13 Thread jet speed
Thanks - Shaji, Uri and Shawn for your valuable inputs. Apprecaite it. Cheers ! On Fri, Dec 13, 2013 at 3:33 PM, Uri Guttman u...@stemsystems.com wrote: On 12/13/2013 10:21 AM, Shaji Kalidasan wrote: Greetings, Thanks a bunch Uri and Shawn for providing valuable inputs. Here is the

Re: Array elements in Hash

2012-10-05 Thread Shekar
Statton lawre...@cluon.comwrote: On 10/04/2012 11:26 AM, jet speed wrote: Hi All, I am trying to find the array elements in hash, if it matches then print the hash value. Please help me to achieve this. Note: array elements matches the first 2 characters of the hash keys. @match = (6c7b00

Re: Array elements in Hash

2012-10-05 Thread jet speed
', '6d'= 'device5', '6e'= 'device3', '6g'='device9'); foreach my $element(@match) { print $element.=.$abc{substr($element, 0, 2)}.\n; } if i understand right, the loop scrolls through the array elements and prints the hash value if it matches the first 2 character. pls correct me if am wrong

Re: Array elements in Hash

2012-10-05 Thread Shekar
'); foreach my $element(@match) { print $element.=.$abc{substr($element, 0, 2)}.\n; } if i understand right, the loop scrolls through the array elements and prints the hash value if it matches the first 2 character. pls correct me if am wrong, Thanks Sj On Fri, Oct 5, 2012 at 7:23

Re: Array elements in Hash

2012-10-05 Thread jet speed
, 6c6863, 6e6632); %abc = ('6c' ='device1', '6d'= 'device5', '6e'= 'device3', '6g'='device9'); foreach my $element(@match) { print $element.=.$abc{substr($element, 0, 2)}.\n; } if i understand right, the loop scrolls through the array elements and prints the hash value

Array elements in Hash

2012-10-04 Thread jet speed
Hi All, I am trying to find the array elements in hash, if it matches then print the hash value. Please help me to achieve this. Note: array elements matches the first 2 characters of the hash keys. @match = (6c7b00, 6d7b00, 6d9d8f, 6c6863, 6e6632); %abc = ('6c' = device1, '6d'=device5, '6e

Re: Array elements in Hash

2012-10-04 Thread David Precious
On Thu, 4 Oct 2012 17:26:23 +0100 jet speed speedj...@googlemail.com wrote: I am trying to find the array elements in hash, if it matches then print the hash value. Please help me to achieve this. Note: array elements matches the first 2 characters of the hash keys. @match = (6c7b00

Re: Array elements in Hash

2012-10-04 Thread Lawrence Statton
On 10/04/2012 11:26 AM, jet speed wrote: Hi All, I am trying to find the array elements in hash, if it matches then print the hash value. Please help me to achieve this. Note: array elements matches the first 2 characters of the hash keys. @match = (6c7b00, 6d7b00, 6d9d8f, 6c6863, 6e6632

print 2 array elements

2012-09-05 Thread jet speed
Hi All, I would like to print array1 with array2 as below ex: output --- abc-12 20/1 def-22 30/22 ghi-33 40/3 def-22 20/1 @array1 =abc-12, def-22, ghi-33,abc-12,def-22; @array2 =20/1, 30/22, 40/3, 20/1; i did try to map array1 to array2 elements, did'nt work. %hash = map {$array1[$_]

Re: print 2 array elements

2012-09-05 Thread Shlomi Fish
Hi jet speed, On Wed, 5 Sep 2012 11:47:41 +0100 jet speed speedj...@googlemail.com wrote: Hi All, I would like to print array1 with array2 as below ex: output --- abc-12 20/1 def-22 30/22 ghi-33 40/3 def-22 20/1 The best way would be to iterate over the indexes: for my

Re: print 2 array elements

2012-09-05 Thread jet speed
Thanks Sholmi. Appreciate your help !. that's correct, i did make up the syntax, bec's the actual program is in a different system, were i cannot access mail. Cheers Sj On Wed, Sep 5, 2012 at 12:10 PM, Shlomi Fish shlo...@shlomifish.org wrote: Hi jet speed, On Wed, 5 Sep 2012 11:47:41

Re: print 2 array elements

2012-09-05 Thread Dr.Ruud
On 2012-09-05 12:47, jet speed wrote: output --- abc-12 20/1 def-22 30/22 ghi-33 40/3 def-22 20/1 @array1 =abc-12, def-22, ghi-33,abc-12,def-22; @array2 =20/1, 30/22, 40/3, 20/1; i did try to map array1 to array2 elements, did'nt work. %hash = map {$array1[$_] = $array2[$_] }

Re: matching array elements from hash ?

2012-09-01 Thread Dr.Ruud
On 2012-08-20 00:18, John W. Krahn wrote: print map exists $stud{ $_ } ? $_ = $stud{ $_ }\n : (), @names; A map using a ternary with (), is like a grep: print $_ = $stud{ $_ }\n for grep exists $stud{ $_ }, @names; -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: matching array elements from hash ?

2012-08-20 Thread jet speed
On Sun, Aug 19, 2012 at 10:48 PM, timothy adigun 2teezp...@gmail.comwrote: Hi, Please, Check my comments below. On 8/19/12, jet speed speedj...@googlemail.com wrote: Hi All, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky

Re: matching array elements from hash ?

2012-08-20 Thread jet speed
Thanks John, worked as a treat. Appreciate it. On Sun, Aug 19, 2012 at 11:18 PM, John W. Krahn jwkr...@shaw.ca wrote: jet speed wrote: Hi All, Hello, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( abc = 34, nba =99

Re: matching array elements from hash ?

2012-08-20 Thread Andy Bach
On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun 2teezp...@gmail.com wrote: foreach my $match_value ( sort keys %stud ) { print $match_value, =, $stud{$match_value}, $/ if $match_value ~~ @names; } smart match is a Perl 6 (though it probably back ported to a Perl 5 module?)

Re: matching array elements from hash ?

2012-08-20 Thread Jim Gibson
The smart match operator (~~) was introduced in Perl 5.10. If you are using a Perl earlier than that, you will get a syntax error. See perldoc perl5100delta perldoc perlsyn and search for Smart. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail:

Re: matching array elements from hash ?

2012-08-20 Thread timothy adigun
Hi, Hi Tim, Thanks, i tried to run the code, but get the error as below. Any thing i am missing line 17. What version of Perl are you using? For smart matching to work you must have Perl 5.10.1 Up (the 5.10.0 version behaved differently). syntax error at ./match2.pl line 17, near

Re: matching array elements from hash ?

2012-08-20 Thread timothy adigun
Hi Andy, On 8/20/12, Andy Bach afb...@gmail.com wrote: On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun 2teezp...@gmail.com wrote: foreach my $match_value ( sort keys %stud ) { print $match_value, =, $stud{$match_value}, $/ if $match_value ~~ @names; } smart match is a Perl 6

matching array elements from hash ?

2012-08-19 Thread jet speed
Hi All, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( abc = 34, nba =99, def =24, ghi= 33); How can i go throught each elements of has %stud and print the matching array value in this case abc =34 def=24 Thanks Sj

Re: matching array elements from hash ?

2012-08-19 Thread timothy adigun
Hi, Please, Check my comments below. On 8/19/12, jet speed speedj...@googlemail.com wrote: Hi All, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); The above should be @names=(abc,def,ghi,jky); OR @names=qw(abc def ghi jky

Re: matching array elements from hash ?

2012-08-19 Thread John W. Krahn
jet speed wrote: Hi All, Hello, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( abc = 34, nba =99, def =24, ghi= 33); How can i go throught each elements of has %stud and print the matching array value in this case abc =34

Array elements

2012-07-02 Thread Yuma More
Hi there: I am very new in Perl and I am trying to write a script to search for similar text in two different files, If it founds a match, it should out put the whole line from the second file in a third file. Let say that my first file (F1) has a list of some samples like

Re: Array elements

2012-07-02 Thread Shlomi Fish
Hi Yuma, a few comments on your code. On Mon, 2 Jul 2012 23:10:36 +1000 Yuma More yuma...@gmail.com wrote: Hi there: I am very new in Perl and I am trying to write a script to search for similar text in two different files, If it founds a match, it should out put the whole line from the

Re: Array elements

2012-07-02 Thread Chris Charley
Hi there: I am very new in Perl and I am trying to write a script to search for similar text in two different files, If it founds a match, it should out put the whole line from the second file in a third file. Let say that my first file (F1) has a list of some samples like

Re: Array elements

2012-07-02 Thread Yuma More
Than you Chris, your scrip is very helpful and know about BioPerl Module also. I appreciated it . On Mon, Jul 2, 2012 at 11:55 PM, Chris Charley char...@pulsenet.com wrote: Hi there: I am very new in Perl and I am trying to write a script to search for similar text in two different files,

Re: How to merge multiple array elements

2012-01-16 Thread Igor Dovgiy
2012/1/15 Pradeep Patra smilesonisa...@gmail.com I want to merge more than 2 arrays. @array = (@array1,@array2,@array3,@array4); print Array elements:@array; It works and displays 1-12. But I need something different because i dont know the value of n beforehand. What do you mean by 'n

How to merge multiple array elements

2012-01-15 Thread Pradeep Patra
Hi all, I want to merge more than 2 arrays. For example: @array1 = (1,2,3); @array2 = (4,5,6); @array3 = (7,8,9); @array4 = (10,11,12); my @array; @array = (@array1,@array2,@array3,@array4); print Array elements:@array; It works and displays 1-12. But I need something different because

Re: How to merge multiple array elements

2012-01-15 Thread Jeff Peng
于 2012-1-16 1:18, Pradeep Patra 写道: It works and displays 1-12. But I need something different because i dont know the value of n beforehand. So I decided to use a for loop. I tried push but it did not work. I would appreciate any help to merge multiple array elements preferably not using any

Re: How to merge multiple array elements

2012-01-15 Thread Uri Guttman
On 01/16/2012 12:12 AM, Jeff Peng wrote: Consider the code below, though eval a string is considered bad way generally. eval string is bad generally? it is bad UNLESS you need it. and you don't need it here. the OP's problem is also very poorly stated. are the arrays related by name? if

Re: move array elements to hash

2011-04-17 Thread Jim Gibson
At 12:29 PM -0700 4/14/11, mark baumeister wrote: Hi, I am trying to move array elements (populated from the STDIN) into a hash as pairs [i] and [i + 1] and then print them out using the code below. If I enter bob as the first element and hit enter I get the error messages below. I guess

move array elements to hash

2011-04-16 Thread mark baumeister
Hi, I am trying to move array elements (populated from the STDIN) into a hash as pairs [i] and [i + 1] and then print them out using the code below. If I enter bob as the first element and hit enter I get the error messages below. I guess there are multiple problems with my code. For one

Re: move array elements to hash

2011-04-16 Thread Shawn H Corey
On 11-04-14 03:29 PM, mark baumeister wrote: #create key - value pairs to go into a hash by first entering each into a list @k or @v print input key/value pairs: first a key then return, then a value then return, etc. To stop entering key/value pairs type 'stop'\n; while ($kv =STDIN) {

Re: move array elements to hash

2011-04-16 Thread Rob Dixon
On 14/04/2011 20:29, mark baumeister wrote: Hi, I am trying to move array elements (populated from theSTDIN) into a hash as pairs [i] and [i + 1] and then print them out using the code below. If I enter bob as the first element and hit enter I get the error messages below. I guess

Re: move array elements to hash

2011-04-16 Thread John W. Krahn
mark baumeister wrote: Hi, Hello, I am trying to move array elements (populated from theSTDIN) into a hash as pairs [i] and [i + 1] and then print them out using the code below. If I enter bob as the first element and hit enter I get the error messages below. I guess there are multiple

Re: help with array elements

2011-03-12 Thread Parag Kalra
could some one throw some light on how i can do this. thanks in advance.. use strict; use warnings; my @array = (1,2,3,4,2,3,1,2,1,1,1,4,6,7); my %hash; foreach my $item (@array){ if (exists $hash{$item}) { $hash{$item} = $hash{$item} + 1; } else { $hash{$item} = 1;

Re: help with array elements

2011-03-12 Thread Alan Haggai Alavi
Hello Ashwin, I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array. for example 1-5 times 2-3 times... could some one throw some light on how i can do this. Store the array contents into a hash,

Re: help with array elements

2011-03-12 Thread Uri Guttman
PK == Parag Kalra paragka...@gmail.com writes: PK my @array = (1,2,3,4,2,3,1,2,1,1,1,4,6,7); PK my %hash; PK foreach my $item (@array){ PK if (exists $hash{$item}) { PK $hash{$item} = $hash{$item} + 1; PK } else { PK $hash{$item} = 1; PK } PK } this

Re: help with array elements

2011-03-12 Thread magnus
On 2011-03-12 13:17, ashwin ts wrote: Hi, Hello, I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array. for example 1-5 times 2-3 times... Use a hash. #!/usr/bin/perl use

Re: help with array elements

2011-03-12 Thread Paul Johnson
On Sat, Mar 12, 2011 at 09:20:01AM +0100, mag...@trapd00r.se wrote: On 2011-03-12 13:17, ashwin ts wrote: I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array. for example 1-5 times

Re: help with array elements

2011-03-12 Thread ashwin ts
help. Thanks again, Regards Ashwin Thayyullathil Surendran -- Forwarded message -- From: ashwin ts ashwint...@gmail.com Date: Sat, Mar 12, 2011 at 1:17 PM Subject: help with array elements To: beginners@perl.org Hi, I am a newbie to perl. I have an array which has few elements

Re: help with array elements

2011-03-12 Thread Rob Dixon
On 12/03/2011 15:41, ashwin ts wrote: Thank you all for the support.It helped me a lot.i tried working with arrays as well as with hash.Both the approaches works fine in the case of a small array with few elements. When i tried the same for a large array , i started getting out of memory error.

Re: help with array elements

2011-03-12 Thread kurtz le pirate
In article AANLkTi=afy09dh8c2f3tmncjcm4om1ihgutacaln_...@mail.gmail.com, ashwint...@gmail.com (ashwin ts) wrote: Hi, I am a newbie to perl. I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array.

Re: help with array elements

2011-03-12 Thread Shawn H Corey
On 11-03-12 10:56 AM, kurtz le pirate wrote: quick write, not tested I suggest you test it. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and communication as it is about coding. The secret to

Re: help with array elements

2011-03-12 Thread John Delacour
At 03:14 -0500 12/03/2011, Uri Guttman wrote: this replaces the entire if/else statement: $hash{$item}++ ; ...it is a standard perl idiom you need to know so you don't waste code like that. Nice! so #!/usr/local/bin/perl use strict; my %hash; my @array = split //, 12342312111467;

Re: help with array elements

2011-03-12 Thread Paul Johnson
On Sat, Mar 12, 2011 at 05:31:06PM +, Rob Dixon wrote: On 12/03/2011 15:41, ashwin ts wrote: Thank you all for the support.It helped me a lot.i tried working with arrays as well as with hash.Both the approaches works fine in the case of a small array with few elements. When i tried the

Re: help with array elements

2011-03-12 Thread Paul Johnson
On Sat, Mar 12, 2011 at 01:35:31PM -0500, Shawn H Corey wrote: On 11-03-12 10:56 AM, kurtz le pirate wrote: quick write, not tested I suggest you test it. Is this general advice or do you see a problem with the code? If it is the former, I agree. If it is the latter, please point out the

help with array elements

2011-03-11 Thread ashwin ts
Hi, I am a newbie to perl. I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array. for example 1-5 times 2-3 times... could some one throw some light on how i can do this. thanks in

Re: printing array elements

2008-10-13 Thread Mr. Shawn H. Corey
On Mon, 2008-10-13 at 14:04 +0100, Rob Dixon wrote: A program with arrays that are tied in one place and not in another has bigger problems than this anyway. But I don't see a problem with using $ with tied arrays, unless the tied class happens to overload stringification. print

Re: printing array elements

2008-10-13 Thread Jenda Krynicky
From: Rob Dixon [EMAIL PROTECTED] Jenda Krynicky wrote: From: Dr.Ruud [EMAIL PROTECTED] Jenda Krynicky schreef: Rob Dixon: local $ = ','; print @array\n; print join(',', @array), \n; is much cleaner and safer. Leave $ alone. I don't agree. It is totally fine to use a

Re: printing array elements

2008-10-13 Thread Rob Dixon
Mr. Shawn H. Corey wrote: On Mon, 2008-10-13 at 14:04 +0100, Rob Dixon wrote: A program with arrays that are tied in one place and not in another has bigger problems than this anyway. But I don't see a problem with using $ with tied arrays, unless the tied class happens to overload

Re: printing array elements

2008-10-13 Thread Rob Dixon
Jenda Krynicky wrote: From: Rob Dixon [EMAIL PROTECTED] Jenda Krynicky wrote: From: Dr.Ruud [EMAIL PROTECTED] Jenda Krynicky schreef: Rob Dixon: local $ = ','; print @array\n; print join(',', @array), \n; is much cleaner and safer. Leave $ alone. I don't agree. It is totally fine

Re: printing array elements

2008-10-13 Thread Chas. Owens
On Mon, Oct 13, 2008 at 10:50, Rob Dixon [EMAIL PROTECTED] wrote: snip Then we must remain in disagreement. I believe that because perldoc perlvar is so easy to access, and because it also provides mnemonics for each symbolic variable, the Huffman encoding principle is paramount here. snip

Re: printing array elements

2008-10-13 Thread Rob Dixon
Jenda Krynicky wrote: From: Dr.Ruud [EMAIL PROTECTED] Jenda Krynicky schreef: Rob Dixon: local $ = ','; print @array\n; print join(',', @array), \n; is much cleaner and safer. Leave $ alone. I don't agree. It is totally fine to use a local-ed $, if it is inside a minimal block.

Re: printing array elements

2008-10-13 Thread Mr. Shawn H. Corey
On Mon, 2008-10-13 at 12:15 -0400, Chas. Owens wrote: But You are typing more. If you were making the claim that { local @ = , ; print buy @a1\nsell @a2\nkeep @a3\n; } was easier to type than print buy , join(', ', @a1), \n, sell , join(', ', @a2), \n, keep ,

Re: printing array elements

2008-10-13 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Mon, 2008-10-13 at 14:04 +0100, Rob Dixon wrote: A program with arrays that are tied in one place and not in another has bigger problems than this anyway. But I don't see a problem with using $ with tied arrays, unless the tied class happens to overload

Re: printing array elements

2008-10-12 Thread Jenda Krynicky
From: Rob Dixon [EMAIL PROTECTED] Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc.

Re: printing array elements

2008-10-12 Thread Dr.Ruud
Jenda Krynicky schreef: Rob Dixon: local $ = ','; print @array\n; print join(',', @array), \n; is much cleaner and safer. Leave $ alone. I don't agree. It is totally fine to use a local-ed $, if it is inside a minimal block. -- Affijn, Ruud Gewoon is een tijger. -- To

Re: printing array elements

2008-10-12 Thread Jenda Krynicky
From: Dr.Ruud [EMAIL PROTECTED] Jenda Krynicky schreef: Rob Dixon: local $ = ','; print @array\n; print join(',', @array), \n; is much cleaner and safer. Leave $ alone. I don't agree. It is totally fine to use a local-ed $, if it is inside a minimal block. Is it? What if

Re: printing array elements

2008-10-10 Thread Dr.Ruud
Rob Dixon schreef: print @array\n; will output the elements separated with spaces by default. To change the separator to a comma you can write local $ = ','; print @array\n; Please present code like that with enclosing curlies, to limit the scope of the local $. -- Affijn, Ruud

printing array elements

2008-10-09 Thread Charlie Farinella
I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc. } I normally just print them as above, but I'm thinking there must be a

Re: printing array elements

2008-10-09 Thread Martin Barth
Hey, print $array[0],$array[1],$array[2]; etc. There are different ways: 1) print @array; usually you want to see which element is at which index so 2) print join( - , @array); is maybe better. HTH Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: printing array elements

2008-10-09 Thread Charlie Farinella
On Thursday 09 October 2008, Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc. } I normally

Re: printing array elements

2008-10-09 Thread Rob Dixon
Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc. } I normally just print them as above,

Re: printing array elements

2008-10-09 Thread John W. Krahn
Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc. } I normally just print them as above, but I'm

Re: printing array elements

2008-10-09 Thread Mr. Shawn H. Corey
On Thu, 2008-10-09 at 16:53 -0400, Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while (INFILE) { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print $array[0],$array[1],$array[2]; etc. } I

sorting array of array of array elements

2008-04-22 Thread Süleyman Gülsüner
Hi All, I am trying to sort some data, which originally came as an excel file. There are main titles, sub titles, sub sub titles and sub sub sub titles. They defined by using different levels of indents in the original file. I parse it and convert indents into spaces. Main titles are sorted by

loop auto-incrementing array elements

2007-06-13 Thread Gian Sartor
Hi All, I have a list in the following format - room surname firstnames What I would like to is read the file into an array and combine the firstname and surname onto the same line and ignore the room. Below is an example of what I want to do - @line = ; $surname = $line[1]; chomp

Re: loop auto-incrementing array elements

2007-06-13 Thread Paul Lalli
On Jun 13, 10:23 am, [EMAIL PROTECTED] (Gian Sartor) wrote: Hi All, I have a list in the following format - room surname firstnames What I would like to is read the file into an array and combine the firstname and surname onto the same line and ignore the room. Below is an example of

Re: loop auto-incrementing array elements

2007-06-13 Thread Chas Owens
On 6/13/07, Gian Sartor [EMAIL PROTECTED] wrote: Hi All, I have a list in the following format - room surname firstnames What I would like to is read the file into an array and combine the firstname and surname onto the same line and ignore the room. Below is an example of what I want to do -

Re: loop auto-incrementing array elements

2007-06-13 Thread Gian Sartor
Gian Sartor wrote: Hi All, I have a list in the following format - room surname firstnames What I would like to is read the file into an array and combine the firstname and surname onto the same line and ignore the room. Below is an example of what I want to do - Thanks to Paul and Chas.

Re: counting scalar array elements question

2006-03-09 Thread Hans Meier (John Doe)
John W. Krahn am Donnerstag, 9. März 2006 03.36: Hans Meier (John Doe) wrote: [...] my @array; #or: my @array=(); [v--- this sidenote is wrong] (sidenote: the second form must be used in contexts where the code is persistent/preloaded and used several times, to ensure that @array is

counting scalar array elements question

2006-03-08 Thread Graeme McLaren
Hi all, I have an array question: If I have a variable, $var, and it contains an array how would I be able to easily count the number of elements in the array? I've tried creating a new array and pushing the original array on to it but that creates an array of arrays. Basically I have: my

RE: counting scalar array elements question

2006-03-08 Thread Timothy Johnson
To: beginners@perl.org Subject: counting scalar array elements question Hi all, I have an array question: If I have a variable, $var, and it contains an array how would I be able to easily count the number of elements in the array? I've tried creating a new array and pushing the original array

Re: counting scalar array elements question

2006-03-08 Thread Hans Meier (John Doe)
From: Graeme McLaren [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 08, 2006 3:57 PM To: beginners@perl.org Subject: counting scalar array elements question Hi all, I have an array question: If I have a variable, $var, and it contains an array how would I be able to easily

Re: counting scalar array elements question

2006-03-08 Thread John W. Krahn
Hans Meier (John Doe) wrote: From: Graeme McLaren [mailto:[EMAIL PROTECTED] If I have a variable, $var, and it contains an array how would I be able to easily count the number of elements in the array? I've tried creating a new array and pushing the original array on to it but that creates

How to enumerate array elements?

2004-09-02 Thread Siegfried Heintze
Consider the following program: my $me; $me-{verd_result}-[0][2]=5; $me-{verd_result}-[0][5]=34; print len = , [EMAIL PROTECTED]{verd_result}-[0]}}; for (@{$me-{verd_result}-[0]}){ print \n v=; print; } It produces this output: len = 5 v= v= v=5 v= v= v=34 How do I

Re: How to enumerate array elements?

2004-09-02 Thread Gunnar Hjalmarsson
Siegfried Heintze wrote: Consider the following program: my $me; $me-{verd_result}-[0][2]=5; $me-{verd_result}-[0][5]=34; print len = , [EMAIL PROTECTED]{verd_result}-[0]}}; for (@{$me-{verd_result}-[0]}){ print \n v=; print; } How is that related to CGI? It produces this output: len = 5 v= v=

Re: How to enumerate array elements?

2004-09-02 Thread Gunnar Hjalmarsson
Charles K. Clarkson wrote: Gunnar Hjalmarsson wrote: Siegfried Heintze wrote: Consider the following program: my $me; $me-{verd_result}-[0][2]=5; $me-{verd_result}-[0][5]=34; print len = , [EMAIL PROTECTED]{verd_result}-[0]}}; for (@{$me-{verd_result}-[0]}){ print \n v=; print; } It produces

RE: printing array elements in columns

2004-06-21 Thread N, Guruguhan \(GEAE, Foreign National, EACOE\)
. Regards Guruguhan -Original Message- From: N, Guruguhan (GEAE, Foreign National, EACOE) Sent: Friday, June 18, 2004 5:08 PM To: [EMAIL PROTECTED] Subject: printing array elements in columns Hi All, I have a one dimensional array @X, containing N elements. I would like

RE: printing array elements in columns

2004-06-21 Thread Charles K. Clarkson
N, Guruguhan (GEAE, Foreign National, EACOE) wrote: : In reply to my own posting, I have written a code : like the one given below. : : @X = (1 .. 30); : : $n_el = scalar(@X); : $n_row = $n_el/3; # 3 is the number of columns I want. : : for ($i=0; $i$n_row; $i++) { : for

Re: printing array elements in columns

2004-06-21 Thread Zeus Odin
Guruguhan N [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi All, Hello. Please read Charles K. Clarkson's comments. They are spot on. I will not repeat them here. In reply to my own posting, I have written a code like the one given below. @X = (1 .. 30) $n_el = scalar(@X);

printing array elements in columns

2004-06-18 Thread N, Guruguhan \(GEAE, Foreign National, EACOE\)
Hi All, I have a one dimensional array @X, containing N elements. I would like to know how I can print this N elements in M columns? TIA Guruguhan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: printing array elements in columns

2004-06-18 Thread Edward Wijaya
On Fri, 18 Jun 2004 17:08:08 +0530, N, Guruguhan (GEAE, Foreign National, EACOE) [EMAIL PROTECTED] wrote: Hi All, I have a one dimensional array @X, containing N elements. I would like to know how I can print this N elements in M columns? print join(\n, @X), \n; Or if you have

RE: printing array elements in columns

2004-06-18 Thread Tim Johnson
; } -Original Message- From: N, Guruguhan (GEAE, Foreign National, EACOE) [mailto:[EMAIL PROTECTED] Sent: Fri 6/18/2004 4:38 AM To: [EMAIL PROTECTED] Cc: Subject: printing array elements in columns Hi All, I have a one dimensional array @X, containing N elements. I would

RE: printing array elements in columns

2004-06-18 Thread Bob Showalter
N, Guruguhan (GEAE, Foreign National, EACOE) wrote: Hi All, I have a one dimensional array @X, containing N elements. I would like to know how I can print this N elements in M columns? If you want the data to read across, then down, you can do: @X = 'A' .. 'Z'; $m = 8;

Form field named as array elements

2003-11-14 Thread Mayo, Chuck
as array elements: form input type=text name=question{'25'} value=$answer{'25'} input type=text name=question{'47'} value=$answer{'47'} /form Then when the form came back in, create update statements from the key/value pairs. while (($key,$value) = each %question

RE: Form field named as array elements

2003-11-14 Thread Mayo, Chuck
: Friday, November 14, 2003 2:19 PM To: Mayo, Chuck; '[EMAIL PROTECTED]' Subject: Re: Form field named as array elements Hi all, I need to present a series of database fields for users to update and when the form is submitted I need to be able to retrieve not only the field

RE: Form field named as array elements

2003-11-14 Thread Wiggins d Anconia
Works like a charm, thanks! Guess I was trying to make it to difficult. I must've done something wrong, though... I had to alter the code a bit to make it work. It seemed that grabbing all the params tossed the param values and I had to go back and get 'em once I had the key isolated.

Comparing array elements with scalar variables.

2002-10-30 Thread jonathan . musto
. OPTION VALUE=MAYMAY OPTION VALUE=JUNJUN OPTION VALUE=JULJUL OPTION VALUE=AUGAUG OPTION VALUE=SEPSEP OPTION SELECTED=OCTOCT i've tried many ways of doing this and it seems that perl can't compare scalar variable with array elements, does anyone know of a way of doing this?? any help would be much

Re: Comparing array elements with scalar variables.

2002-10-30 Thread Nigel Wetters
On Wed, 2002-10-30 at 09:33, [EMAIL PROTECTED] wrote: my @emonth; while ( @emonth = $end_Months-fetchrow_array()) { print HTML OPTION VALUE=\@emonth\@emonth\n; } Grab the month from the database row before writing the line: while ( my @row = $sth-fetchrow_array()) { my $month =

Re: Comparing array elements with scalar variables.

2002-10-30 Thread Nigel Wetters
On Wed, 2002-10-30 at 09:33, [EMAIL PROTECTED] wrote: I've have some code that prints a column of a database table into a html form. The column of the table is just the last 6 months of the year: see previous post database lookups are expensive. the last 6 months of the year are fairly

RE: Comparing array elements with scalar variables.

2002-10-30 Thread jonathan . musto
;rivalsdm.com] Sent: Wednesday, October 30, 2002 09:59 To: Musto,J,Jonathan,IVYD3 C Cc: [EMAIL PROTECTED] Subject: Re: Comparing array elements with scalar variables. On Wed, 2002-10-30 at 09:33, [EMAIL PROTECTED] wrote: I've have some code that prints a column of a database table into a html form

  1   2   >