Re: HoA building

2006-12-28 Thread Chad Perrin
I sent a message to the list already mentioning that after checking perldoc -f split one more time I found where it mentioned using a quoted literal space as the matching pattern. For some reason, it seems that nobody saw the message, because I have seen several messages so far quoting the releva

Re: HoA building

2006-12-28 Thread Dr.Ruud
Chad Perrin schreef: > [split works differently with ' ', /\s/, /\s+/] > Why doesn't perldoc -f split say anything about that? Never mind, I > guess that's a rhetorical question. It is all in the documentation: [...] By default, empty leading fields are preserved, and empty trailing ones a

Re: HoA building

2006-12-28 Thread M. Lewis
Igor Sutton wrote: 2006/12/28, Chad Perrin <[EMAIL PROTECTED]>: On Thu, Dec 28, 2006 at 03:31:36AM -0500, M. Lewis wrote: > > Chad, I've been experimenting with this a bit since your posting. Maybe > this will help: (I'm trying to understand the diff too) > > perl -le' > my $ln = "one two thr

Re: HoA building

2006-12-28 Thread Chad Perrin
On Thu, Dec 28, 2006 at 02:01:54AM -0700, Chad Perrin wrote: > > Why doesn't perldoc -f split say anything about that? Never mind, I > guess that's a rhetorical question. Igor just pointed out to me that it is, in fact, in perldoc -f split, and I just managed to miss it when I looked through it

Re: HoA building

2006-12-28 Thread Chad Perrin
On Thu, Dec 28, 2006 at 08:51:26AM +, Igor Sutton wrote: > 2006/12/28, Chad Perrin <[EMAIL PROTECTED]>: > > > >That makes sense, considering I just checked the tutorials at PerlMonks > >and discovered that, according to split(), ' ' and /\s+/ are exactly the > >same. Frankly, I find that a bit

Re: HoA building

2006-12-28 Thread Igor Sutton
2006/12/28, Chad Perrin <[EMAIL PROTECTED]>: On Thu, Dec 28, 2006 at 03:31:36AM -0500, M. Lewis wrote: > > Chad, I've been experimenting with this a bit since your posting. Maybe > this will help: (I'm trying to understand the diff too) > > perl -le' > my $ln = "one two three four "; > print

Re: HoA building

2006-12-28 Thread Igor Sutton
Hi Chad, 2006/12/28, Chad Perrin <[EMAIL PROTECTED]>: [snip] Actually, on second thought, I seem to recall that ' ' has a meaning in split() beyond a literal space. Unfortunately, I don't recall exactly what that is. I've tried looking it up using perldoc -f split and in several books I ha

Re: HoA building

2006-12-28 Thread Chad Perrin
On Thu, Dec 28, 2006 at 03:31:36AM -0500, M. Lewis wrote: > > Chad, I've been experimenting with this a bit since your posting. Maybe > this will help: (I'm trying to understand the diff too) > > perl -le' > my $ln = "one two three four "; > print map " |$_| ", split /\s/, $ln; > print map "

Re: HoA building

2006-12-28 Thread M. Lewis
Chad Perrin wrote: John W. Krahn wrote: M. Lewis wrote: while (my $ln = ){ chomp $ln; my ($prod, $flavor) = split /\s/, $ln, 2; You probably should use ' ' instead of /\s/ as the first argument to split: my ($prod, $flavor) = split ' ', $ln, 2; Ok, but why? Are they not the same?

Re: HoA building

2006-12-27 Thread Chad Perrin
On Wed, Dec 27, 2006 at 10:58:40PM -0700, Chad Perrin wrote: > On Wed, Dec 27, 2006 at 07:42:59PM -0500, M. Lewis wrote: > > John W. Krahn wrote: > > >M. Lewis wrote: > > >> > > >>while (my $ln = ){ > > >>chomp $ln; > > >>my ($prod, $flavor) = split /\s/, $ln, 2; > > > > > >You probably sho

Re: HoA building

2006-12-27 Thread M. Lewis
John W. Krahn wrote: my ($prod, $flavor) = split /\s/, $ln, 2; You probably should use ' ' instead of /\s/ as the first argument to split: my ($prod, $flavor) = split ' ', $ln, 2; Ok, but why? Are they not the same? No. $ perl -le' my $ln = " one two three four "; print map "

Re: HoA building

2006-12-27 Thread Chad Perrin
On Wed, Dec 27, 2006 at 07:42:59PM -0500, M. Lewis wrote: > John W. Krahn wrote: > >M. Lewis wrote: > >> > >>while (my $ln = ){ > >>chomp $ln; > >>my ($prod, $flavor) = split /\s/, $ln, 2; > > > >You probably should use ' ' instead of /\s/ as the first argument to split: > > > > my ($pr

Re: HoA building

2006-12-27 Thread John W. Krahn
M. Lewis wrote: > > John W. Krahn wrote: >> M. Lewis wrote: >>> >>> my ($prod, $flavor) = split /\s/, $ln, 2; >> >> You probably should use ' ' instead of /\s/ as the first argument to >> split: >> >> my ($prod, $flavor) = split ' ', $ln, 2; > > Ok, but why? Are they not the same? No.

Re: HoA building

2006-12-27 Thread M. Lewis
Thanks John and Zhao, John W. Krahn wrote: M. Lewis wrote: I have the following simple script. I'm toying with HoA for the first time. The script is not working as expected and I know why it's not working. Each time a $HoA{$prod} is read, the $flavor is replaced with the new value. It would se

RE: HoA building

2006-12-27 Thread zhao_bingfeng
> -Original Message- > From: M. Lewis [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 27, 2006 3:36 PM > To: beginners@perl.org > Subject: HoA building > > I have the following simple script. I'm toying with HoA for the first > time. The script is not working as expected and I know

Re: HoA building

2006-12-27 Thread John W. Krahn
M. Lewis wrote: > I have the following simple script. I'm toying with HoA for the first > time. The script is not working as expected and I know why it's not > working. Each time a $HoA{$prod} is read, the $flavor is replaced with > the new value. > > It would seem that I need to push the $flavor