Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> If there is anything I didn't explain well, just say so. > > Good job on your attempts. > > Steve > Thank you very much! I am very grateful for your help and explanations. Take care, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h.

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 23:15, Chris Stinemetz wrote: ok. You didn't do anything wrong per-se, all you did was try to go one level too deep into your data structure. $cell (eg 149) was the name of the key for the top-level %hash container. All hash keys can only have one value associated with it. In t

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > replace all of this: > > >>   foreach my $hr ( sort keys %{ $href->{$cell}} ) { >>     # print "\t$hr"; >>     foreach my $count ( sort keys %{ $href->{$cell}->{$hr}} ) { #<-- line >> 48 >>     print "\t$count"; >>     } >>   } > > > ...with this: > > >    foreach my $hr ( sort keys %{ $href->{

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 22:39, Chris Stinemetz wrote: Use a block sort to sort numerically: perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' Show us what you have so far if you need help with a specific code segment. references are still a bit foreighn to me. Below is the error I am ge

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > Use a block sort to sort numerically: > > perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' > > Show us what you have so far if you need help with a specific code segment. > references are still a bit foreighn to me. Below is the error I am getting along with the snippit of code.

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 22:13, Chris Stinemetz wrote: Any advice on how to include a numerical sort on the second key? I've been trying to resolve this for a while and have had no luck. Use a block sort to sort numerically: perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' Show us what y

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
On Mar 25, 2012 11:15 AM, "Steve Bertrand" wrote: > > On 2012-03-25 12:02, Chris Stinemetz wrote: >> >> How would I return the values along with the keys that meet the criteria >> from the sub routine? > > >> On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: > > > Keeping with the use of $_, replace t

Re: ASCII/binary endline character trouble

2012-03-25 Thread timothy adigun
Hi Fred, Please, check my comments and possible solution within your mail. On Sun, Mar 25, 2012 at 11:45 PM, hOURS wrote: > Hello all, > I write CGI scripts for my website in PERL. When I used to upload them > with my FTP > The programming language is Perl not PERL. > program I made sure to

ASCII/binary endline character trouble

2012-03-25 Thread hOURS
Hello all, I write CGI scripts for my website in PERL.  When I used to upload them with my FTP program I made sure to do so in ASCII mode rather than binary.  My host made me switch to sFTP however.  I use FIlezilla, and can't for the life of me find out how to choose the mode on that.  Unfortun

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> code snippet: > my $href = %data; > I changed my $href = %data; to my $href = \%data; and it works now. Thanks all, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > Keeping with the use of $_, replace the following 'print map' statement to > the following: > > >>> print map "$_\n", @wanted; > > > foreach ( @wanted ){ >    print "$_:\n"; >    foreach ( values %{ $href->{ $_ } } ){ >       print "\t$_\n"; >    } > } > > ** OUTPUT ** > > 149: >        2 >    

Re: Why do I get a warning?

2012-03-25 Thread Uri Guttman
On 03/25/2012 09:11 AM, Peter Scott wrote: On Thu, 22 Mar 2012 20:06:35 -0400, Uri Guttman wrote: no one uses braces for single scalar handles in general. I do. Ever since Damian recommended it (Perl Best Practices, page 217). One of those numerous times I didn't agree with him until I trie

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 12:02, Chris Stinemetz wrote: How would I return the values along with the keys that meet the criteria from the sub routine? On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: Keeping with the use of $_, replace the following 'print map' statement to the following: print map "$_

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
Thank you. How would I return the values along with the keys that meet the criteria from the sub routine? Thanks! Chris On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: > On 25/03/2012 14:11, Chris Stinemetz wrote: > >> Below is snippet from Data::Dumper dump from a hash I have. >> >> What is the

Re: printing hashes

2012-03-25 Thread Rob Dixon
On 25/03/2012 14:11, Chris Stinemetz wrote: Below is snippet from Data::Dumper dump from a hash I have. What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does below. '149' => { '05

Re: printing hashes

2012-03-25 Thread Dr.Ruud
On 2012-03-25 15:11, Chris Stinemetz wrote: What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does below. Code it, in Perl. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional comman

printing hashes

2012-03-25 Thread Chris Stinemetz
Below is snippet from Data::Dumper dump from a hash I have. What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does below. '149' => { '05' => '1', '06' => '1',

Re: Why do I get a warning?

2012-03-25 Thread Peter Scott
On Thu, 22 Mar 2012 20:06:35 -0400, Uri Guttman wrote: > no one uses braces for single scalar handles in general. I do. Ever since Damian recommended it (Perl Best Practices, page 217). One of those numerous times I didn't agree with him until I tried it, then found he was right. -- Peter S

Re: perl match

2012-03-25 Thread Rob Dixon
On 25/03/2012 10:23, lina wrote: > > For > > Rissman, R.; Poon, W. W.; Blurton, M.; Oddo, S.; Torp, R. > > I wish to get the output as > > R. Risman and W. W. Pooon and M. Blurtoon and S. Oddoo and R. Toorp, R. > > Here is the code I came up so far, which works partially > > > #!/usr/bin/en

perl match

2012-03-25 Thread lina
Hi, For Rissman, R.; Poon, W. W.; Blurton, M.; Oddo, S.; Torp, R. I wish to get the output as R. Risman and W. W. Pooon and M. Blurtoon and S. Oddoo and R. Toorp, R. Here is the code I came up so far, which works partially #!/usr/bin/env perl use strict; use warnings; use 5.012; my $str=$