grab pattern from start and end block

2013-07-12 Thread Agnello George
hi i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data in the following format name:agnello, dob:23 april ,address:

Re: grab pattern from start and end block

2013-07-12 Thread Shawn H Corey
On Fri, 12 Jul 2013 17:14:42 +0530 Agnello George wrote: > i have raw data that is like this in a flat file . > > start > name:agnello > dob:2 april > address:123 street > end > start > name:babit > dob:13 april > address:3 street > end > start > name:ganesh > dob:1 april > address:23 street > e

Re: grab pattern from start and end block

2013-07-12 Thread Agnello George
could i use local $/ instead of $INPUT_RECORD_SEPARATOR On Fri, Jul 12, 2013 at 5:33 PM, Shawn H Corey wrote: > On Fri, 12 Jul 2013 17:14:42 +0530 > Agnello George wrote: > > > i have raw data that is like this in a flat file . > > > > start > > name:agnello > > dob:2 april > > address:123

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 12:44, Agnello George wrote: hi i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data in the following

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 13:30, Agnello George wrote: could i use local $/ instead of $INPUT_RECORD_SEPARATOR Yes, and you should do that. The extended variable names are almost never used and will mostly confuse people familiar with Perl. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@per

Re: grab pattern from start and end block

2013-07-12 Thread Shawn H Corey
On Fri, 12 Jul 2013 13:51:01 +0100 Rob Dixon wrote: > On 12/07/2013 13:30, Agnello George wrote: > > > > could i use local $/ instead of $INPUT_RECORD_SEPARATOR > > Yes, and you should do that. The extended variable names are almost > never used and will mostly confuse people familiar with

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 13:56, Shawn H Corey wrote: On Fri, 12 Jul 2013 13:51:01 +0100 Rob Dixon wrote: On 12/07/2013 13:30, Agnello George wrote: could i use local $/ instead of $INPUT_RECORD_SEPARATOR Yes, and you should do that. The extended variable names are almost never used and will mostl

Re: grab pattern from start and end block

2013-07-12 Thread John W. Krahn
Agnello George wrote: hi Hello, i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data in the following format na

Re: grab pattern from start and end block

2013-07-12 Thread Hal Wigoda
TMTOWTDI On Fri, Jul 12, 2013 at 7:03 AM, Shawn H Corey wrote: > On Fri, 12 Jul 2013 17:14:42 +0530 > Agnello George wrote: > > > i have raw data that is like this in a flat file . > > > > start > > name:agnello > > dob:2 april > > address:123 street > > end > > start > > name:babit > > dob:13

Re: grab pattern from start and end block

2013-07-12 Thread Dr.Ruud
On 12/07/2013 13:44, Agnello George wrote: hi i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data in the following

Re: grab pattern from start and end block

2013-07-12 Thread Nathan Hilterbrand
> On 12/07/2013 13:44, Agnello George wrote: >> hi >> >> i have raw data that is like this in a flat file . >> >> start >> name:agnello >> dob:2 april >> address:123 street >> end >> start >> name:babit >> dob:13 april >> address:3 street >> end >> start >> name:ganesh >> dob:1 april >> address

Re: grab pattern from start and end block

2013-07-12 Thread Dr.Ruud
On 12/07/2013 20:19, Nathan Hilterbrand wrote: On 12/07/2013 13:44, Agnello George wrote: i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street

Re: grab pattern from start and end block

2013-07-12 Thread Nathan Hilterbrand
> On 12/07/2013 20:19, Nathan Hilterbrand wrote: >>> On 12/07/2013 13:44, Agnello George wrote: > i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address

Re: grab pattern from start and end block

2013-07-12 Thread John W. Krahn
Dr.Ruud wrote: On 12/07/2013 13:44, Agnello George wrote: hi i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data

Re: grab pattern from start and end block

2013-07-12 Thread galeb abu-ali
#!/usr/bin/perl use Modern::Perl '2011'; use autodie; my @a; while( <> ) { chomp; my @temp if /^start$/; if( /^end$/ ) { push @a, [ @temp ]; } else { push @temp, $_; } } for my $name ( @a ) { say join ", ", @$name; } On Fri, Jul 12, 2013 at 8:39 PM, John

Re: grab pattern from start and end block

2013-07-12 Thread *Shaji Kalidasan*
gift to you. What you do with it is your gift back to God. --- From: Agnello George To: Perl Beginners Sent: Friday, 12 July 2013 5:14 PM Subject: grab pattern from start and end block

Re: grab pattern from start and end block

2013-07-12 Thread John Delacour
On 12/7/13 at 17:35, rvtol+use...@isolution.nl (Dr.Ruud) wrote: perl -0 -wple 's/^start\n(.*?)\nend\n/$_=$1;y{\n}{ };"$_\n"/emgs' Pure obfuscation! Why not keep things simple?! These stupid one-liners are a pain in the brain. #!/usr/bin/perl use strict; my @items; while (<>) { # or use a

Re: grab pattern from start and end block

2013-07-13 Thread Uri Guttman
On 07/13/2013 02:55 AM, John Delacour wrote: #!/usr/bin/perl use strict; my @items; while (<>) { # or use a file handle chomp; next if /^start/; if (/^end/) { print join ", ", @items; print "\n"; undef @items; that is the wrong way to clear an array (o

Re: grab pattern from start and end block

2013-07-13 Thread Rob Dixon
On 12/07/2013 12:44, Agnello George wrote: hi i have raw data that is like this in a flat file . start name:agnello dob:2 april address:123 street end start name:babit dob:13 april address:3 street end start name:ganesh dob:1 april address:23 street end i need to get the data in the following

Re: grab pattern from start and end block

2013-07-13 Thread shawn wilson
There's enough code here that I'm not even going to try. However, your data looks almost like json (minus the quoting). If this is the case, you'll probably want to build up an array of hashes and use JSON::XS. On Jul 13, 2013 6:16 AM, "Rob Dixon" wrote: > On 12/07/2013 12:44, Agnello George wrot