Re: Counter Help

2016-02-12 Thread Kent Fredric
On 13 February 2016 at 10:08, Kent Fredric wrote: > > All you're doing is sorting the *view* of it. Not the data itself. If you want a demonstration of this fact, on a Linux filesystem, poke around with 'find'. Or if you've got Path::Iterator::Rule installed: perl -MPIR -E' $it = PIR->new->ite

Re: Counter Help

2016-02-12 Thread Kent Fredric
On 13 February 2016 at 08:38, timothy adigun <2teezp...@gmail.com> wrote: > In your analogy, if hashes are like folder, keys and values are like what? > Name of folders. If yes, can those be sorted? If yes, they you have just > made my point.. :) Keys are files. Values are file contents. B

RE: Counter Help

2016-02-12 Thread uri
On Fri, February 12, 2016 12:37 pm, Christin Deville wrote: > I have been lurking for a while but I want to chime in and say thanks for > that piece of advice. I've been trying to sort out in my head when to use > a hash or an array and this all helps! > > in real world code you should be using ha

Re: Counter Help

2016-02-12 Thread timothy adigun
On Feb 12, 2016 8:28 PM, "Kent Fredric" wrote: > > On 13 February 2016 at 07:39, timothy adigun <2teezp...@gmail.com> wrote: > > And hashes keys/values can't be sorted? Just saying.. :) > > > In my other message where I give an analogy to a "Folder" or > "Directory" in a file system. In your analo

Re: Counter Help

2016-02-12 Thread Kent Fredric
On 13 February 2016 at 07:39, timothy adigun <2teezp...@gmail.com> wrote: > And hashes keys/values can't be sorted? Just saying.. :) In my other message where I give an analogy to a "Folder" or "Directory" in a file system. Can you sort a folder? ... not really. They don't really have an "order"

Re: Counter Help

2016-02-12 Thread Kent Fredric
On 10 February 2016 at 03:46, James Kerwin wrote: > (I'm a bit wary of hashes because they're weird). If you want a nice way to reason about hashes when you're really new, there's something that you probably already understand you can borrow understanding from: Folders. A hash is like a folder

Re: Counter Help

2016-02-12 Thread timothy adigun
On Feb 12, 2016 6:22 PM, "Shawn H Corey" wrote: > > On Fri, 12 Feb 2016 12:08:07 -0500 > Uri Guttman wrote: > > > hashes are very easy to learn. and once you get the hang of them you > > will wonder why you waited so long. > > If keeping the data ordering is important, And hashes keys/values can'

RE: Counter Help

2016-02-12 Thread Christin Deville
riday, February 12, 2016 10:21 AM To: beginners@perl.org Subject: Re: Counter Help On Fri, 12 Feb 2016 12:08:07 -0500 Uri Guttman wrote: > hashes are very easy to learn. and once you get the hang of them you > will wonder why you waited so long. If keeping the data ordering is important, u

Re: Counter Help

2016-02-12 Thread Uri Guttman
On 02/12/2016 04:33 AM, James Kerwin wrote: Thank you all for your help; all suggestions were welcome and helpful. I didn't give the full details but Jim's solution did what I wanted the best and after reading around I think I get it. I've sat here trying to "break" it for the past half an hou

Re: Counter Help

2016-02-12 Thread Shawn H Corey
On Fri, 12 Feb 2016 12:08:07 -0500 Uri Guttman wrote: > hashes are very easy to learn. and once you get the hang of them you > will wonder why you waited so long. If keeping the data ordering is important, use an array. Otherwise, use a hash. :) -- Don't stop where the ink does. Shaw

Re: Counter Help

2016-02-12 Thread James Kerwin
Thank you all for your help; all suggestions were welcome and helpful. I didn't give the full details but Jim's solution did what I wanted the best and after reading around I think I get it. I've sat here trying to "break" it for the past half an hour and so far so good. I solemnly swear to prope

Re: Counter Help

2016-02-09 Thread Jim Gibson
> On Feb 9, 2016, at 6:46 AM, James Kerwin wrote: > > Thank you both very much for your help. I'll investigate this way when I get > home later (I'm a bit wary of hashes because they're weird). Here is a solution using a hash: #!/usr/bin/perl use strict; use warnings; my @array = qw{

Re: Counter Help

2016-02-09 Thread Shlomi Fish
Hi Duncan and James, On Tue, 9 Feb 2016 14:58:05 + Duncan Ferguson wrote: > I disagree – hashes are not weird – they are incredibly useful. It is just > an array indexed by a word instead of a number ☺ > I agree with Duncan here. Hashes are an integral part of idiomatic Perl and one shou

Re: Counter Help

2016-02-09 Thread Nathan Hilterbrand
On 02/09/2016 09:08 AM, James Kerwin wrote: Afternoon all, I have the following problem: I have an array containing a list of non-unique strings. eg: @array Contains: 11_ 22_ 33_ 33_ 33_ 44_ 44_ 55_ What I would like to do is number each element of the array

RE: Counter Help

2016-02-09 Thread Duncan Ferguson
=$key:", $/; # print out the indexes of items in the local array print " $key$_",$/ foreach (0 .. $#arr) } Duncs From: James Kerwin [mailto:jkerwin2...@gmail.com] Sent: 09 February 2016 14:47 Cc: beginners@perl.org Subject: Re: Counter Help Thank you both very much

Re: Counter Help

2016-02-09 Thread James Kerwin
Thank you both very much for your help. I'll investigate this way when I get home later (I'm a bit wary of hashes because they're weird). As my files are sorted numerically I managed to do the following (it's ugly, please don't shout at me): my $length = (scalar @New)-1; #print $length; push (my

Re: Counter Help

2016-02-09 Thread Jing Yu via beginners
Hello, I don’t know whether it is possible to count the occurrence in hash? print $var, $myhash{$var}++.”\n”; Jing > On 9 Feb 2016, at 14:08, James Kerwin wrote: > > Afternoon all, > > I have the following problem: > > I have an array containing a list of non-unique strings. eg: > > @array

Re: Counter Help

2016-02-09 Thread Jim Gibson
> On Feb 9, 2016, at 6:08 AM, James Kerwin wrote: > > Afternoon all, > > I have the following problem: > > I have an array containing a list of non-unique strings. eg: > > @array Contains: > > 11_ > 22_ > 33_ > 33_ > 33_ > 44_ > 44_ > 55_ > > What I would lik

Counter Help

2016-02-09 Thread James Kerwin
Afternoon all, I have the following problem: I have an array containing a list of non-unique strings. eg: @array Contains: 11_ 22_ 33_ 33_ 33_ 44_ 44_ 55_ What I would like to do is number each element of the array to look as follows: 11_1 22_1 33_1