Re: Two questions about split and map in a cookbook recipe

2008-11-17 Thread John W. Krahn
Telemachus wrote: On Mon Nov 17 2008 @ 10:21, John W. Krahn wrote: Set paragraph mode. while (<>) { Read a paragraph into $_. In your example a paragraph is: " field:value field:value field:value " my @fields = split /^([^:]+):\s*/m; Since there are multiple lines in a parag

Re: Two questions about split and map in a cookbook recipe

2008-11-17 Thread Chas. Owens
On Mon, Nov 17, 2008 at 13:21, John W. Krahn <[EMAIL PROTECTED]> wrote: snip >> push(@Array_of_Records, { map /(.*)/, @fields }); > > Store the fields as a hash at the end of @Array_of_Records. The filter > /(.*)/ ensures that no newlines are included in the keys or values of the > hash. snip

Re: Two questions about split and map in a cookbook recipe

2008-11-17 Thread Telemachus
On Mon Nov 17 2008 @ 10:21, John W. Krahn wrote: > Set paragraph mode. > >> while (<>) { > > Read a paragraph into $_. In your example a paragraph is: > > " field:value > field:value > field:value > > " > >> my @fields = split /^([^:]+):\s*/m; > > Since there are multiple lines in a p

Re: Two questions about split and map in a cookbook recipe

2008-11-17 Thread John W. Krahn
Telemachus wrote: Good morning, Hello, I'm using a recipe from The Perl Cookbook (11.10 for anyone browsing at home) to produce a record structure from items in a text file. The text file itself has a simple structure: field:value field:value field:value field:value field:value

Two questions about split and map in a cookbook recipe

2008-11-17 Thread Telemachus
Good morning, I'm using a recipe from The Perl Cookbook (11.10 for anyone browsing at home) to produce a record structure from items in a text file. The text file itself has a simple structure: field:value field:value field:value field:value field:value etc. That is, the records are