RE: what is something like this - $seen{$1}

2004-10-26 Thread Bob Showalter
rs wrote: > Hi, > Here's a snippet of some code from the cookbook. Hmm, time to get a new cookbook :~) > I am trying to understand what $seen{$1} is. ie where did $1 come > from, and what is in $seen{$1}, and how is the hash populated? $1 is a built-in variable that is set by capturing parens in

Re: what is something like this - $seen{$1}

2004-10-26 Thread Errin Larsen
On Tue, 26 Oct 2004 16:50:11 -0400, Bob Showalter <[EMAIL PROTECTED]> wrote: > rs wrote: > > Hi, > > Here's a snippet of some code from the cookbook. > > Hmm, time to get a new cookbook :~) Nope. Just make sure you understand the the OP changed the code quoted from the cookbook, and that the c

Re: what is something like this - $seen{$1}

2004-10-26 Thread Errin Larsen
> > %seen = ( ); > $string = "an apple a day"; > foreach $char (split //, $string) { > $seen{$char}++; > } > print "unique chars are: ", sort(keys %seen), "\n"; > > Also, a couple of paragraphs later, the Cookbook goes on to show how > to solve the same problem with a while loop a

Re: what is something like this - $seen{$1}

2004-10-26 Thread Chasecreek Systemhouse
Interesting. Why doesn't this skip already seen letters, I used the case-insensitive modifier... %seen = ( ); $string = "AaBbCcDdEeFf"; while ($string =~ /(.)/gi) { $seen{$1}++; } print "\n\nunique chars are: ", sort(keys %seen), "\n"; 'A' and 'a' are the same, or is the logic only char() or

Re: what is something like this - $seen{$1}

2004-10-26 Thread Chasecreek Systemhouse
Simply put, the dot (.) matches everything regardless of modifier switch. -- WC -Sx- Jones http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: what is something like this - $seen{$1}

2004-10-26 Thread Dan Jones
On Tue, 2004-10-26 at 22:00, Chasecreek Systemhouse wrote: > Interesting. > > Why doesn't this skip already seen letters, I used the > case-insensitive modifier... > > %seen = ( ); > $string = "AaBbCcDdEeFf"; > while ($string =~ /(.)/gi) { > $seen{$1}++; > } > print "\n\nunique chars are: ",